okay, two very silly Ruby on Rails questions (I just started using RoR a couple of hours ago). Question 1: hello.controller class HelloController < ApplicationController def index(incoming_value) @my_variable = incoming_value * 2 end end How do I call this method with say, the value of 5? I just want to send a value as a parameter from index.rhtml and the controller to display the value * 2. I''m a Java programmer so I''m completely lost here. Question 2: How would one go about to first create a input form which takes a password and then if the user types the correct password, make the controller redirect the user to page2.rhtml? I''m guessing I have to use some sort of form helper here, but the concepts are all so new to me that I''m more intimidated than motivated at the moment. Thanks! -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Since you''re new, please do yourself a favor and learn Ruby first: http://learnruby.com/sites.html has links to a few good tutorials (why''s poignant guide is odd, but can be useful). Then, once you''re somewhat comfortable with Ruby, start learning Rails: http://rails.homelinux.org/ is a great starter tutorial. Also, if you can pick up books, look for the "Agile Development with Rails" and the "Pragmatic Programmers Guide to Ruby" books to get you started. Jason On 12/4/06, Js <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > okay, two very silly Ruby on Rails questions (I just started using RoR a > couple of hours ago). > > Question 1: > hello.controller > > class HelloController < ApplicationController > > def index(incoming_value) > @my_variable = incoming_value * 2 > end > > end > > How do I call this method with say, the value of 5? I just want to send > a value as a parameter from index.rhtml and the controller to display > the value * 2. I''m a Java programmer so I''m completely lost here. > > Question 2: > How would one go about to first create a input form which takes a > password and then if the user types the correct password, make the > controller redirect the user to page2.rhtml? I''m guessing I have to use > some sort of form helper here, but the concepts are all so new to me > that I''m more intimidated than motivated at the moment. > > Thanks! > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 12/4/06, Js <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > How do I call this method with say, the value of 5? I just want to send > a value as a parameter from index.rhtml and the controller to display > the value * 2. I''m a Java programmer so I''m completely lost here.This should go as a helper instead. Helpers are methods (functions) accessible from your views (rhtml files). In your Hello Helper file you would have: def times_two(incoming_value) incoming_value * 2 end In your Hello Controller, your index method would simply be: def index end Which calls your hello/index.rthml file, where you would have: <%= times_two(5) %> Which should display 10. -- "Impossible is nothing." --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
A big thanks to the both of you, I''ll pick up a book and try to take a couple of baby steps a day :) It''s just that nearly all Ruby tutorials are based on building small CRUD applications so it''s hard to find bits and pieces of information like this on the web. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---