Ruby on Rails Friday, July 30, 2010

Manu Lorenzo wrote:
> def try_to_login(antonio)
> antonio = users(:one)
> #post :login, :user => { :screen_name => user.screen_name, :email =>
> user.email, :password => user.password }
> #post :login, :screen_name => antonio.screen_name, :email =>
> antonio.email, :password => antonio.password
> assert logged_in?
> end
>
> If I uncomment the first post line, I get "undefined local method or
> variable 'user' for UserControllerTest, even though I have a model
> called User.rb with a table called users in my database.
> However, if I comment that line and uncomment the second post line,
> everything works like a charm.. could anyone tell me why?

user.screen_name # where is user defined?

The problem is exactly what the error message is telling you "undefined
local method or variable 'user'."

antonio is defined on the first line of the method so
antonio.screen_name is perfectly valid.
--
Posted via http://www.ruby-forum.com/.

--
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.

No comments:

Post a Comment