Ruby on Rails
Friday, February 12, 2016
On Tuesday, 9 February 2016 18:21:15 UTC-6, Ankit Raj wrote:
On Wednesday, February 10, 2016 at 12:00:42 AM UTC+5:30, Matt Jones wrote:
On Tuesday, 9 February 2016 12:20:37 UTC-6, Ankit Raj wrote:Hello geeks,
Help me in solving following error.
No route matches {:action=>"create_banner_text", :controller=>"websites", :id=>nil} missing required keys: [:id]
Detail is given on
https://gist.github.com/aj07/794468a5f6f92ea63dfb On line 48 of the template, you have:create_banner_text_website_path(@website) The error indicates that @website is nil, so the create_banner_text_website_path route helper can't generate a URL. You didn't show the controller code, but that's where I'd recommend you start looking.--Matt Jones
my controller code
[snip]
def load_website
@website ||= current_ngo.websites.where(name: params[:template]).first_or_ initialize
Looks like I misinterpreted your error in my original reply. This line is the issue. If the call to `first_or_initialize` returns an unsaved object, then a route like
resources :websites, only: [:index, :create] do
member do
get :create_banner_text
isn't going to be able to generate a URL, since the unsaved object doesn't have an ID.
--Matt Jones
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/2c4fc5e7-2685-439a-82db-ca2b7cb85900%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment