Rendering data in tables

Hello all,

I am new to Rails.
I don’t know whether it is possible are not.

In my application, I need get data from one table , then arrange these
data in table in textfield, then I need to edit data in all rows in
single form.

At the end I need to save these data back to databse.

How can I do this

Is this possible

<%= tag(“input” , {:type => ‘’, :id=>"<%= %> " … %>

Thanks in advance

1 Table or 1 Record only? if in 1 table it means that
ModelName.find(:all)
Both 1 table or 1 record from ActiveRecord action can be saved in 1
field or column as textfield. If you call data from table it will be
provided in array unless you call data only sigle record like
ModelName.find(id), it would be hash form. If array is saved to a column
of a table. The array would be formed as YAML.

sai wrote:

In my application, I need get data from one table , then arrange these
data in table in textfield, then I need to edit data in all rows in
single form.
At the end I need to save these data back to databse.

How can I do this

Is this possible

Yes you can do it.

@test = Employee.find(:all)

#it will save all data of table Employee
#in only 1 column as text field in ImportEmployee Table.

@other = ImportEmployee.new
@other.old_employee = @test
@other.save!

#to call back data and edit it then save it to Employee.
#you can use it

@other = ImportEmployee.find(params[:id])

@employees = YAML.load(@other.old_employee)

in your view to edit

<% form_tag :action => ‘your_method’ do %>

<% for employ in @employees %>

<%= text_field ‘employee[id][]’, :value=> employ.id %>
<%= text_field ‘employee[column_1][]’, :value=> employ.column_1 %>
.
.
.
<% end %> <%#–end for— %>
<% end %> <%#–end form— %>

Then in your controller

def your_method

for param in params[:employee]
@save_employee = Employee.find(param[:id])
@save_employee.update_attributes(param)
end

#maybe when you run my code, it would be error, because i not try it
#but the algo is closed like that, we can try by doing.

<%= tag(“input” , {:type => ‘’, :id=>"<%= %> " … %>

Dont use double <%= %>,it will be error.

Thanks in advance

You’re Welcome.

Reinhart
http://teapoci.blogspot.com

In my application, I need get data from one table , then arrange these
data in table in textfield, then I need to edit data in all rows in
single form.

At the end I need to save these data back to databse.

Have a look at this plugin:

http://os.flvorful.com/super_in_place_controls

If you’re looking for a spreadsheet-like appearance where you have all
fields as inputs right away, and the database is updated instantly
(onchange) without an OK button, it’s not exactly that. But maybe it’s
customizable, I haven’t really looked into it.

Is this possible

<%= tag(“input” , {:type => ‘’, :id=>"<%= %> " … %>

You can’t wrap a <%= %> inside another. What are you trying to do? If
you
want to calculate the value for id, just omit the quotes:

<%= … , :id => some+ruby.expression, … %>