Hi I want the FORM values on my controller.i.e. I want the values of login_loginname(Form variable) and login_password(Form variable) on login_controller.rb How can i do that? Table Name is: logins Model:: Login.rb Controller:: login_controller.rb Below is my test form loginname password Hoping for reply Regards Parikshit
I can''t see your form, I believe that it might have been missed. Any
how
your form should look something like this:
View:
<%= form_tag %>
<label for="login_loginname">Login Name:</label>
<%= text_field(:login,:loginname) %>
<br/>
<label for="login_password">Password:</label>
<%= password_field(:login,:password) %>
<br/>
<br/>
<input type="submit" value="submit" />
<%= end_form_tag %>
controller:
def action_name
if request.post?
user = Login.new(params[:login])
# user now contains the values that were entered in the form
# do what you need
end
end
Regards,
David.
parikshit wrote:>
> Hi
>
> I want the FORM values on my controller.i.e. I want the values of
> login_loginname(Form variable) and login_password(Form variable) on
> login_controller.rb
> How can i do that?
>
> Table Name is: logins
> Model:: Login.rb
> Controller:: login_controller.rb
>
> Below is my test form
>
>
>
> loginname
>
>
>
> password
>
>
>
>
>
> Hoping for reply
> Regards
> Parikshit
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
Hi, you should be able to access this values within your controller as follows: @login = @params["login_loginname"] @password = @params["login_password"] Peace, -Conrad On 4/6/06, parikshit <parikshit.mishra@wwindia.com> wrote:> > Hi > > I want the FORM values on my controller.i.e. I want the values of login_loginname(Form variable) and login_password(Form variable) on login_controller.rb > How can i do that? > > Table Name is: logins > Model:: Login.rb > Controller:: login_controller.rb > > Below is my test form > > > > loginname > > > > password > > > > > > Hoping for reply > Regards > Parikshit > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
@params is deprecated, use params[] instead. -- -- Tom Mornini On Apr 6, 2006, at 12:40 AM, Conrad Taylor wrote:> Hi, you should be able to access this values within your controller > as follows: > > @login = @params["login_loginname"] > @password = @params["login_password"] > > Peace, > > -Conrad > > On 4/6/06, parikshit <parikshit.mishra@wwindia.com> wrote: >> >> Hi >> >> I want the FORM values on my controller.i.e. I want the values of >> login_loginname(Form variable) and login_password(Form variable) >> on login_controller.rb >> How can i do that? >> >> Table Name is: logins >> Model:: Login.rb >> Controller:: login_controller.rb >> >> Below is my test form >> >> >> >> loginname >> >> >> >> password >> >> >> >> >> >> Hoping for reply >> Regards >> Parikshit >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
I can''t see your form, I believe that it might have been missed. Any
how
your form should look something like this:
View:
<%= form_tag %>
<label for="login_loginname">Login Name:</label>
<%= text_field(:login,:loginname) %>
<br/>
<label for="login_password">Password:</label>
<%= password_field(:login,:password) %>
<br/>
<br/>
<input type="submit" value="submit" />
<%= end_form_tag %>
controller:
def action_name
if request.post?
user = Login.new(params[:login])
# user now contains the values that were entered in the form
# do what you need
end
end
Regards,
David.
parikshit wrote:>
> Hi
>
> I want the FORM values on my controller.i.e. I want the values of
> login_loginname(Form variable) and login_password(Form variable) on
> login_controller.rb
> How can i do that?
>
> Table Name is: logins
> Model:: Login.rb
> Controller:: login_controller.rb
>
> Below is my test form
>
>
>
> loginname
>
>
>
> password
>
>
>
>
>
> Hoping for reply
> Regards
> Parikshit
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
You should get them in params[:login] -- Posted via http://www.ruby-forum.com/.
if request.post? @user = Login.new(params[:login]) render_text @user.loginname now i want to compare this value by existig value how i can do tha . plese suggest thanx in advance
On Apr 7, 2006, at 7:45, parikshit wrote:> if request.post? > @user = Login.new(params[:login]) > render_text @user.loginname > now i want to compare this value by existig value how i can do tha .You''re creating a brand new Login object, not updating an existing, so there can''t really be an existing value to compare with. Do you want something like @user = Login.find(params[:id]) @user.update(params[:login]) render(:text => "New login name: #{@user.loginname}") @olduser = Login.find(@user.id) render(:text => "Old login name: #{@olduser.loginname}") instead? -- Jakob Skjerning - http://mentalized.net
Hi.
Does anybody knows if there is a way to grab input form values when
creating links through rails; something that would look like the following :
link_to "search", { :action => "search" }, :with_values
=>
''my_input_field_name''
that would create, via some generated javascript function :), a dynamic
link to
/main/search?my_input_field_name=123
Note that my_input_field_name would be the result of a
text_field_with_auto_complete so there is not necessary a form in the
page.. Am i asking too much out of Rails ?
Thanks for any help
Stan
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060606/0e991443/attachment.html
Wilson Bilkovich
2006-Jun-07 09:03 UTC
[Rails] How to add Form values to a url using helper
On 6/6/06, ??? ????? <smazurek@doubleclick.ne.jp> wrote:> > Hi. > > Does anybody knows if there is a way to grab input form values when > creating links through rails; something that would look like the following : > > link_to "search", { :action => "search" }, :with_values => > ''my_input_field_name'' > > that would create, via some generated javascript function :), a dynamic > link to > > /main/search?my_input_field_name=123 > > Note that my_input_field_name would be the result of a > text_field_with_auto_complete so there is not necessary a form in the page.. > Am i asking too much out of Rails ? >This should do it: (untested, of course) link_to "search", { :action => "search" }, :with => "''some_param='' + escape(some_value)" More common is a form_remote_tag, which does the tedious work for you. Also see link_to_remote and remote_function, in the API docs.