dracos
October 5, 2007, 2:29am
1
I am trying to implement a basic login page:
login.rhtml
1
2 <% form_tag do %>
3 Name:
4 <%= text_field_tag :name, params[:name] %>
5 Password:
6 <%= password_field_tag :password, params[:password] %>
7 <%= submit_tag “Login” %>
8 <% end %>
9
However, I’m getting the following error on line 4:
undefined method `tr’ for :name:Symbol
Am I using text_field_tag incorrectly? Here is my controller:
LoginController < Application Controller
1 def login
2 session[:user_id] = nil
3 if request.post?
4 user = User.authenticate(params[:name], params[:password])
5 if user
6 session[:user_id] = user.id
7 redirect_to(:action => “index”)
8 else
9 flash.now[:notice] = “Invalid user/password combination”
10 end
11 end
12 end
dracos
October 5, 2007, 2:39am
2
No, everything looks fine. I copy / pasted your view code into a test
view and it rendered find. Can you paste the full error output?
Peter M. wrote:
7 <%= submit_tag “Login” %>
11 end
12 end
–
Sincerely,
William P.
dracos
October 5, 2007, 3:23am
3
William P. wrote:
No, everything looks fine. I copy / pasted your view code into a test
view and it rendered find. Can you paste the full error output?
Thanks for your interest William. The complete versions of the pages are
here:
login_controller.rb
http://pastie.caboo.se/103948
login.rhtml
http://pastie.caboo.se/103949
Here is my full error output:
NoMethodError in Login#login
Showing app/views/login/login.rhtml where line #8 raised:
undefined method `tr’ for :name:Symbol
Extracted source (around line #8 ):
5: <% form_tag do %>
6:
7: Name:
8: <%= text_field_tag :name, params[:name] %>
9:
10:
11:
RAILS_ROOT: /Users/petermarks/Documents/Rails/Orbus/config/…
Application Trace | Framework Trace | Full Trace
#{RAILS_ROOT}/vendor/plugins/krjs/lib/krjs.rb:99:in split_dom_id' #{RAILS_ROOT}/vendor/plugins/krjs/lib/krjs.rb:109:in
controller_method’
#{RAILS_ROOT}/vendor/plugins/krjs/lib/krjs.rb:128:in
viewer_method_eventattr' #{RAILS_ROOT}/vendor/plugins/krjs/lib/krjs.rb:70:in
observer’
#{RAILS_ROOT}/vendor/plugins/krjs/lib/krjs.rb:24:in tag' /Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/i386/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_tag_helper.rb:94:in
text_field_tag’
#{RAILS_ROOT}/app/views/login/login.rhtml:8:in
_run_rhtml_47app47views47login47login46rhtml' #{RAILS_ROOT}/app/views/login/login.rhtml:5:in
_run_rhtml_47app47views47login47login46rhtml’
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/i386/bin/mongrel_rails:16:in
`load’
/Applications/Locomotive2/Bundles/standardRailsMar2007.locobundle/i386/bin/mongrel_rails:16
Request
Parameters: None
Show session dump
Response
Headers: {“cookie”=>[], “Cache-Control”=>“no-cache”}
dracos
October 5, 2007, 4:24am
4
Definitely odd, but based on the stack trace, the issue is with a plugin
you have installed, krjs. I am not familiar with it, but according to
the website:
Introducing the KRJS plugin
http://choonkeat.svnrepository.com/svn/rails-plugins/krjs/ , with less
than 60 lines of patch to Rails’ ActionPack itself (which probably
means bugs are aplenty, would slow production sites to a crawl, and
that its fresh from the oven too)
I would try removing this plugin or make sure you are running the latest
version. Looks like the official site is here:
http://choonkeat.svnrepository.com/rails-plugins/trac.cgi/wiki
Hope this helps.
Peter M. wrote:
Parked at Loopia
undefined method `tr’ for :name:Symbol
`_run_rhtml_47app47views47login47login46rhtml’
Response
Headers: {“cookie”=>[], “Cache-Control”=>“no-cache”}
–
Sincerely,
William P.
dracos
October 5, 2007, 4:29am
5
Thank you very much for taking a look at this. I’ll uninstall kjrs and
see what happens.
Thanks again,
Peter
dracos
October 5, 2007, 8:16am
6
Hi Peter
Why don;t you take a look at acts_as_authenticated for guidance ?
On Oct 5, 8:29 am, Peter M. [email protected]
dracos
October 5, 2007, 8:40am
7
Uninstalling the kjrs plugin fixed this right up. Thanks again William.
dracos
October 5, 2007, 4:31am
8
np, let me know what happens.
Peter M. wrote:
Thank you very much for taking a look at this. I’ll uninstall kjrs and
see what happens.
Thanks again,
Peter
–
Sincerely,
William P.