Forum: Ruby on Rails Not sure how to update..

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
93d2b6696403e856cdbb7266223126dd?d=identicon&s=25 Ro Vent (rvent)
on 2007-01-17 22:28
Hello i ve been using RoR for about 3 weeks and i have create a very
simple app to keep track of my tasks. I am having some difficulties on 2
things...

First i have a column named 'priority' on the table 'projects' and i
want to be able to change the color of the entiry row (or at least the
cell) for that project. EX: i have 5 projects being displayed on  a
table two of them are priority 1 and the rest are priority 4. I want to
be able to change the color of the row (or at least the cell) depending
on the priority on the project (1 = red, 2 = orange, 3 = yellow...
etc)... At the creation of the project i can specify the priority, but i
am not sure how to get that number from the SQL database and then
perform the if statements (if thats how it would be done).. Would this
need JavaScript..? AJAX..?

And second i have this check box linked to the 'done' column on the
'projects' table. The the i have the display set up is that it will
display everything that has 'done = 0' (or not done) so as soon i chekc
the done check box it disappears from the list of projects. However
there are 2 things i havent been able to figure out.. How can i have a
prompt asking me if i am sure the project is done..? (similar to the
'destroy" action) And how can i create a timestamp, with the current
date and time, and saved into the 'completed' column....?

here is what i have for the check_box

list.rhtml:
<td><%= check_box("done", "short", "onclick" =>
"document.location.href='/project/toggle_done/#{project.id}'") %></td>

controller:
        def toggle_done
                project = Projects.find(@params["id"])
                project.done = !project.done?

                if project.save
                        redirect_to(:action => "list")
                else
                        render_text "Couldn't add new status"
                end
        end



Any inputs or ideas would be appriciated...


Thanks
This topic is locked and can not be replied to.