Saturday, September 11, 2010

[Rails] Rails 3 helper method not called

While I was trying to port one application from Rail 2 to Rails 3 I've
noticed that helper methods used for rewriting URL paths are not
called. Methods are defined in app/helpers/url_helper.rb:

module UrlHelper
def story_pah(story)
"/story/#{story.title}"
end
end

This method, when called inside of view instead of:

story/1

creates path

story/story_title.

I order to double check this I've create two new applications. One in
Rails 2 and the other in Rails 3. After that I created scaffold for
Story:

Rails 2: script/generate scaffold Story title:string body:string
Rails 3: rails g scaffold Story title:string body:string

Finally I created app/helpers/url_helper.rb with above method in both
applications. In app/views/stories/index.html.erb file line:

<td><%= link_to 'Show', story %></td>

creates: story/story_title in Rails 2 and story/1 path in Rails 3.
Obviously method story_path is not called in Rails 3. Any hint why
this happens would be appreciated.

Regards,
Boško Ivanišević

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate