# Ruby with ajax problem

**URL:** <https://www.ruby-forum.com/t/ruby-with-ajax-problem/173630>\
**Category:** Rails\
**Created:** [August 12, 2009, 11:09am UTC](https://www.ruby-forum.com/t/ruby-with-ajax-problem/173630 "2009-08-12T11:09:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![wap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d9b06d/32.png) [@wap](https://www.ruby-forum.com/u/wap)\
**Post date:** [August 12, 2009, 11:09am UTC](https://www.ruby-forum.com/t/ruby-with-ajax-problem/173630/1 "2009-08-12T11:09:52Z")

</div>

Hello All,

i want to integrate light box ajax feature in my web app so that any  
idea about it.

---

<div class="post-metadata">

**Author:** ![wap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d9b06d/32.png) [@wap](https://www.ruby-forum.com/u/wap)\
**Post date:** [August 12, 2009, 1:30pm UTC](https://www.ruby-forum.com/t/ruby-with-ajax-problem/173630/2 "2009-08-12T13:30:58Z")

</div>

Wap A. wrote:

> Hello All,
> 
> i want to integrate light box ajax feature in my web app so that any  
> idea about it.

It would be better if you put down what you have done so far and where  
exactly you are encountering issues or atleast the procedure to recreate  
the issues you are facing…

without any of these, it sounds as if you want some one to provide you  
an entire working code…

---

<div class="post-metadata">

**Author:** ![wap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d9b06d/32.png) [@wap](https://www.ruby-forum.com/u/wap)\
**Post date:** [August 12, 2009, 1:40pm UTC](https://www.ruby-forum.com/t/ruby-with-ajax-problem/173630/3 "2009-08-12T13:40:40Z")

</div>

ok

 pages addon \<%= stylesheet\_link\_tag 'default' %\> \<%= stylesheet\_link\_tag 'lightbox' %\>

```
  <%= javascript_include_tag 'prototype' %>
  <%= javascript_include_tag 'lightbox' %>

</head>

```

### Listing pages
\<%=lightbox\_link\_to image\_tag 'Christmas Skype.PNG', :class =\> 'lbOn' %\>

\<% for page in @pages %\>

\<% end %\>

| Title | Body | Uname |
| --- | --- | --- |
| \<%=h page.title %\> | \<%=h page.body %\> | \<%=h page.uname %\> | \<%= lightbox\_link\_to 'Show', page, :class =\> 'lbOn'%\> | \<%= link\_to 'Edit', edit\_page\_path(page) %\> | \<%= link\_to 'Destroy', page, :confirm =\> 'Are you sure?', :method =\> :delete %\> |

  
 \<%= link\_to 'New page', new\_page\_path %\> 

click on show lightbox\_link\_to then open box but i got error  
ActionController::InvalidAuthenticityToken in PagesController#1

ActionController::InvalidAuthenticityToken

in this 1 is id from page 1

---

<div class="post-metadata">

**Author:** ![wap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d9b06d/32.png) [@wap](https://www.ruby-forum.com/u/wap)\
**Post date:** [August 12, 2009, 2:30pm UTC](https://www.ruby-forum.com/t/ruby-with-ajax-problem/173630/4 "2009-08-12T14:30:52Z")

</div>

may be you could try this. put it in your controller. Here i assume your  
view is for the action ‘my\_action’

protect\_from\_forgery :except=\>[:my\_action]

let me know how it goes.

---

<div class="post-metadata">

**Author:** ![wap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d9b06d/32.png) [@wap](https://www.ruby-forum.com/u/wap)\
**Post date:** [August 12, 2009, 2:55pm UTC](https://www.ruby-forum.com/t/ruby-with-ajax-problem/173630/5 "2009-08-12T14:55:38Z")

</div>

Rails L. wrote:

> may be you could try this. put it in your controller. Here i assume your  
> view is for the action ‘my\_action’
> 
> protect\_from\_forgery :except=\>[:my\_action]
> 
> let me know how it goes.

i follow ur suggestion but same problem as above

ActionController::InvalidAuthenticityToken in PagesController#1  
ActionController::InvalidAuthenticityToken

i am give procedure

scaffold in page in my project

- in index include lightbox.js, prototype.js, lightbox.css  
-then i can use light box below way

\<%= lightbox\_link\_to 'Show', page, :class =\> 'lbOn'%\> \<%= lightbox\_link\_to 'Edit', edit\_page\_path(page), :class =\> 'lbOn' %\>

show and edit both r inbuild file i want just open through lightbox

---

<div class="post-metadata">

**Author:** ![wap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d9b06d/32.png) [@wap](https://www.ruby-forum.com/u/wap)\
**Post date:** [August 12, 2009, 3:42pm UTC](https://www.ruby-forum.com/t/ruby-with-ajax-problem/173630/6 "2009-08-12T15:42:43Z")

</div>

ok, put this in your controller and see if that works.

skip\_before\_filter :verify\_authenticity\_token

---

<div class="post-metadata">

**Author:** ![wap](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d9b06d/32.png) [@wap](https://www.ruby-forum.com/u/wap)\
**Post date:** [August 13, 2009, 9:50am UTC](https://www.ruby-forum.com/t/ruby-with-ajax-problem/173630/7 "2009-08-13T09:50:06Z")

</div>

In Application controller Try to comment the line

# protect\_from\_forgery # :secret =\> ‘dasdas5484565asdasda’

I too had a similar type of error when i commented that line it  
worked.I dont know if this could be a solution for your problem.  
Any ways lets give a try.
