Answer the question
In order to leave comments, you need to log in
Why are the parameters not coming to the action?
I can't figure out what's wrong. send data with ajax
$(document).ready(function() {
$("#btn").click(function(event) {
event.preventDefault();
$.ajax({
type: 'POST',
url: '/moods',
data: 'rating=4&remark=Boston'
});
});
});
D, [2017-07-19T23:08:22.527103 #19660] DEBUG -- : (0.4ms) BEGIN
D, [2017-07-19T23:08:22.542988 #19660] DEBUG -- : SQL (1.0ms) INSERT INTO "moods" ("created_at", "updated_at") VALUES ($1, $2) RETURNING "id"
D, [2017-07-19T23:08:22.566071 #19660] DEBUG -- : (22.1ms) COMMIT
D, [2017-07-19T23:08:22.567071 #19660] DEBUG -- : (0.4ms) BEGIN
D, [2017-07-19T23:08:22.568624 #19660] DEBUG -- : (0.3ms) COMMIT
127.0.0.1 - - [19/Jul/2017:23:08:22 +0300] "POST /moods HTTP/1.1" 303 - 0.2144
127.0.0.1 - - [19/Jul/2017:23:08:24 +0300] "GET / HTTP/1.1" 200 3714 0.1664
rating=4&remark=Boston
did not come. /moods
, i.e. my create. post '/moods' do
@mood = Mood.create(params[:mood])
if @mood.save
redirect :'/'
else
redirect :'/'
end
end
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question