0

I am trying to generate my CRUD scripts with scaffold_controller I am using:

Loading development environment (Rails 3.0.10) 
ruby-1.9.2-p290 :001 > 

My model is quite simple: class Orgjed < ActiveRecord::Base end And in my schema this is how it writes:

  create_table "orgjeds", :force => true do |t| 
    t.string   "naziv" 
    t.datetime "created_at" 
    t.datetime "updated_at" 
  end 

and I am trying to create controller and all scripts with rails generate scaffold_controller Orgjed After that, script seems to do everything ok:

... 
      create    app/views/orgjeds/index.html.erb 
      create    app/views/orgjeds/edit.html.erb 
... 

After I start a server and try to go to correct path this is what I got back in my browser:

NoMethodError in Orgjeds#index 
Showing xxx/ev_rada/app/views/orgjeds/index.html.erb where line #12 
raised: 
undefined method `orgjed_path' for #<#<Class:0x9fbe1dc>:0x9fb0cf8> 
Extracted source (around line #12): 
9: 
10: <% @orgjeds.each do |orgjed| %> 
11:   <tr> 
12:     <td><%= link_to 'Show', orgjed %></td> 
13:     <td><%= link_to 'Edit', edit_orgjed_path(orgjed) %></td> 
14:     <td><%= link_to 'Destroy', orgjed, :confirm => 'Are you 
sure?', :method => :delete %></td> 
15:   </tr> 

also, I looked into _form.html.erb and there are no fields like naziv... Is it a bug or am I doing something wrong? Thank you

1
  • Have you tried to use the simple rails g scaffold Model attributes? Commented Aug 19, 2011 at 11:58

2 Answers 2

1

Seems like you have missed to configure the routes. Add the following line in routes.rb:

resources :orgjeds
Sign up to request clarification or add additional context in comments.

2 Comments

hm...now I cant even load server, and got this error => Booting WEBrick => Rails 3.0.10 application starting in development on 0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server Exiting /home/dorijan/ruby/ev_rada/config/routes.rb:2:in block in <top (required)>': undefined local variable or method map' for #<ActionDispatch::Routing::Mapper:0x864181c> (NameError), also I got in my routes match ':controller(/:action(/:id(.:format)))'
Have updated my post. If that doesn't work post us your routes.rb
0

I solve the problem by installing and using Niftygenerators

http://compautomatization.blogspot.com/2011/08/ruby-on-rails-3-scaffoldcontroller-not.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.