Post Methods

Hello!, I’m a RoR begginer, i need it to make a web interface for a
bigger project that i’m developing in Ruby, but i don’t know how to do
the next:

I want to read a config file of my main program (a normal conf file),
and be able to change some values.
I take all the names and values pf my config file correctly via a ruby
function, to change the values i think in a form which has a lot of
inputs named like the vars i want to change, and send the new value.
My post command it’s correct for me, it contains the data i want
(something like [name]value[name]value…) , but i don’t know how i
can access to the post variable to work with this data in Ruby ( i
need to write a file [name] \n value …)
The code for my form its:

<% form_for :variable , :legend => “Personal info”, :url => {:action
=> :save_post} do |$dataform| %>
#Read my file …

Name: <%=text_field_tag("#{var_name}", “#{value}”, :size => 20)%>


<%= submit_tag “Change Config File”, :class => “submit” %>

so, how can i access to the post variable?

Thanks!

Within your controller action you can do:

params[:my_param_name]

Assuming you’ve done something like PHP before, it’s the equivalent to
PHP’s:

$_POST[“my_param_name”]

Cheers,

Andy


Andy J.
http://andyjeffries.co.uk/ #rubyonrails #mysql #jquery
Registered address: 64 Sish Lane, Stevenage, Herts, SG1 3LS
Company number: 5452840

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs