Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for URLs with placeholder arguments #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

umjames
Copy link

@umjames umjames commented Nov 24, 2011

In Sinatra, you can specify a URL pattern handler such as /object/:id that will match URLs like /object/1 or /object/5.

I added support for this type of URL to be specified in the URL argument to url_for. If url_for's options argument has a key that equals the placeholder, the value associated with that key will be substituted into the url and that argument is removed from the options.

I added 2 rspec examples that show how this works.

rack/test.  Fixed this by adding the gem to the Gemfile in the test
group and requiring the gems in that group in spec/spec_helper.rb.

Also fixed the rake/rdoctask deprecation warning by adding the rdoc gem
to the gem file and requiring rdoc/task in the Rakefile.

options_used = Set.new

options.each_pair do |placeholder_name, value|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a bug here - method url_for sets options to nil unless options was passed in. So if you don't pass in the optional parameter options you get "undefined method each_pair for nil:NilClass". BTW - the bug above is present in the version obtained from rubygems.org via 'gem install sinatra-url-for"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants