Trying to update a Jquery Sortable list to the database
138 views
Skip to first unread message
tripdragon
unread,
Feb 23, 2012, 2:21:53 AM2/23/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sinatrarb
Using Dattamapper, SQLite
Using Jquery UI's Sortable i'm trying to get the right command syntax
to update the database.
It does not have a url id, or I dont know enough yet to get one via
ajax.
Perhaps I am doing this completly wrong. I could get it to create new
rows on each sortable change. But update requires an :id
If I change a line to u = Sort.update (:sortorder => 1)
I can see that I am sending something. Now how do I get the data from
the sorting. Hmmmm sooo very close.
#app.rb
post '/sort' do
u = Sort.update (:sortorder => 1)
u.updated_at = Time.now
u.save
end
DAZ
unread,
Feb 24, 2012, 2:20:30 AM2/24/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sinatrarb
Can we see more of your code? What is the model you are trying to
update and how do you actually want it sorted?
DAZ
tripdragon
unread,
Feb 24, 2012, 12:00:30 PM2/24/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sinatrarb
> Can we see more of your code? What is the model you are trying to
> update and how do you actually want it sorted?
>
> DAZ
I pasted the bare app with a few puts in the code still as I dig
through it and test.
http://pastebin.com/VAcsZjNs Its end goal is to update the database of the sortment from jQuery UI
Sortables
Currently I have it sending the same id to each row instead of the
assortment.
sqlite> select * from sorts;
491|2|2012-02-24T11:44:19-05:00
492|2|2012-02-24T11:44:19-05:00
493|2|2012-02-24T11:44:19-05:00
494|2|2012-02-24T11:44:19-05:00
when I want for example
sqlite> select * from sorts;
491|4|2012-02-24T11:44:19-05:00
492|1|2012-02-24T11:44:19-05:00
493|2|2012-02-24T11:44:19-05:00
494|3|2012-02-24T11:44:19-05:00
Thank you for your help. I can hop in the irc channel if that helps.
It was pretty quiet there yesterday for anything at all unless there's
a different channel.