Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MODELS
- ======
- class Todo < ActiveRecord::Base
- belongs_to :user
- validates :title, :presence => true, :length => { :maximum => 65 }
- scope :recent, order("created_at DESC")
- scope :incomplete, recent.where(["done = ?", false])
- end
- class User < ActiveRecord::Base
- # Include default devise modules. Others available are:
- # :token_authenticatable, :confirmable, :lockable and :timeoutable
- devise :database_authenticatable, :registerable,
- :recoverable, :rememberable, :trackable, :validatable
- # Setup accessible (or protected) attributes for your model
- attr_accessible :email, :password, :password_confirmation
- has_many :todos
- end
- ROUTES
- ======
- Karya::Application.routes.draw do |map|
- resources :users do
- resources :todos do
- post :mark_done, :on => :collection
- end
- end
- devise_for :users
- root :to => "todos#index"
- end
- PROBLEM WITH form_form (Added new lines to read better)
- =======================================================
- (ruby-1.9.2@dev)(~/projects/karya)९ rails c -s
- Loading development environment in sandbox (Rails 3.0.0.beta4)
- Any modifications you make will be rolled back on exit
- ruby-1.9.2-head > user = User.find(1)
- => #<User id: 1, email: "hello@rohitarondekar.com", encrypted_password: "$2a$10$03wAcpK/y10kGB8pURWHZev4wDexsK2/4Ox8e/elcJjf...", password_salt: "$2a$10$03wAcpK/y10kGB8pURWHZe", reset_password_token: nil, remember_token: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, created_at: "2010-06-24 04:32:58", updated_at: "2010-06-24 04:32:58">
- ruby-1.9.2-head > new_todo = user.todos.new
- => #<Todo id: nil, title: nil, created_at: nil, updated_at: nil, done: false, user_id: 1>
- ruby-1.9.2-head > helper.form_for(new_todo) { |f| f.submit "submit" }
- NoMethodError: undefined method `polymorphic_path' for #<ActionView::Base:0x0000000313aaf8>
- from /home/rohit/.rvm/gems/ruby-1.9.2-head@dev/gems/actionpack-3.0.0.beta4/lib/action_view/helpers/form_helper.rb:329:in `apply_form_for_options!'
- from /home/rohit/.rvm/gems/ruby-1.9.2-head@dev/gems/actionpack-3.0.0.beta4/lib/action_view/helpers/form_helper.rb:301:in `form_for'
- from (irb):3
- from /home/rohit/.rvm/gems/ruby-1.9.2-head@dev/gems/railties-3.0.0.beta4/lib/rails/commands/console.rb:47:in `start'
- from /home/rohit/.rvm/gems/ruby-1.9.2-head@dev/gems/railties-3.0.0.beta4/lib/rails/commands/console.rb:8:in `start'
- from /home/rohit/.rvm/gems/ruby-1.9.2-head@dev/gems/railties-3.0.0.beta4/lib/rails/commands.rb:23:in `<top (required)>'
- from script/rails:9:in `require'
- from script/rails:9:in `<main>'
Add Comment
Please, Sign In to add comment