Forum: Ruby on Rails Post requests exercised as a Get

86da723d3491b2fd3c05293588df6616?d=identicon&s=25 Marcus Smith (marcus_s)
on 2014-03-05 22:28
Hello,
I've been stuck on an issue for a few days now and I haven't been able
to find any help online (asked multiple questions on stackoverflow). I'm
not sure what to do anymore.

Basically, I have a model 'competition' that allows users to attend it.
The user can click 'attend' or 'withdraw' and change their status. it
used to work, but my javascript was messed up and I'm not sure how to
fix it. If anyone could take a look at the question and hopefully help
me out that would be appreciated.

http://stackoverflow.com/questions/22161132/rails-...

Thanks
Bee69cfed999cd13e3bff73d472a39ee?d=identicon&s=25 Hassan Schroeder (Guest)
on 2014-03-05 23:42
(Received via mailing list)
On Wed, Mar 5, 2014 at 1:28 PM, Marcus Smith <lists@ruby-forum.com>
wrote:
> it used to work, but my javascript was messed up

Perhaps you could use `git bisect` to find where it was "messed up"
(or at least go back to before that happened and redo your changes
working forward)

>
http://stackoverflow.com/questions/22161132/rails-...

or alternatively answer the question on your SO post about whether
you're getting any JavaScript errors.

Also, is your markup valid?

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
86da723d3491b2fd3c05293588df6616?d=identicon&s=25 Marcus Smith (marcus_s)
on 2014-03-06 02:24
The only response in the console before I click on withdraw is:

event.returnValue is deprecated. Please use the standard
event.preventDefault() instead

I tried to go back to then (I have everything on github), but I was
unsuccessful in getting it to run. Even if I revert to a previous
commit, it still fails. Not sure what to do now though
Bee69cfed999cd13e3bff73d472a39ee?d=identicon&s=25 Hassan Schroeder (Guest)
on 2014-03-06 19:13
(Received via mailing list)
On Wed, Mar 5, 2014 at 5:24 PM, Marcus Smith <lists@ruby-forum.com>
wrote:

> I tried to go back to then (I have everything on github), but I was
> unsuccessful in getting it to run. Even if I revert to a previous
> commit, it still fails.

You don't have a commit where this runs properly at all? If that's
so, look at your environment. Perhaps you inadvertently updated
a JS library since then? Or added a conflicting gem?

Worst case, start with a clean Rails installation and copy in your
tests and code a bit at a time.

Good luck,
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
F50d3b02eee623a2172b58c09fe31c2c?d=identicon&s=25 mike (Guest)
on 2014-03-07 02:29
(Received via mailing list)
On Wednesday, March 5, 2014 4:28:54 PM UTC-5, Ruby-Forum.com User wrote:
> me out that would be appreciated.
>
>
>
http://stackoverflow.com/questions/22161132/rails-...
>
> Thanks
>
> --
> Posted via http://www.ruby-forum.com/.
>

The message you're getting about event.returnValue is a warning, it
shouldn't be causing your problem.  This is basic, but you didn't show
your
gemfile, I'm assuming you have the gem 'jquery-rails' listed.  Also, it
should be a relatively current version as the older versions had an
issue
with this.  Finally, if there are any jquery files in your
assets/javascripts folder, you should delete them.  I'm covering these
bases only because it sounds like you had an older app that was working
and
were forced to update it.

Other than that, I would follow Hassan's recommendation and rebuild.
Links are not really intended to be used to pass a post, so Rails has
basically rigged it by using javascript to generate a form and submit
it.
 IMO, it's not a great architecture.  If javascript is disabled or there
are errors, it defaults to sending it as a get.  You may want to
consider
using button_to instead of link_to, or you could also change your route
to
"match 'withdraw', via: [:get, :post]" to catch both actions.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.