I have this link in Rails:
<%= link_to "Add to Journal", add_post_journal_path(post), :method => :put %>
However I want transform this link to show a fancybox with the content listing my content to choose. First, I use this code:
<%= link_to "fancy", "#add_post", :class=>"fancybox" %>
but I have errors, because I want pass the actual post to fancybox, so I’m using this code: in add_post.html.erb:
<h1>Escolha o Jornal que deseja adicionar:</h1>
<ul>
<% current_user.journals.each do |journal| %>
<li><%= link_to journal.name,add_post_complete_journal_path(journal),:remote=>true %> </li>
<% end %>
</ul>
and my controller is:
def add_post
@journal_post = JournalsPosts.new
session[:post_add] = params[:id]
end
def add_post_complete
@journal_post = JournalsPosts.create(:post_id => session[:post_add],:journal_id => params[:id])
respond_with @journal_post
end
How can I transform this code to use my content in my fancybox?
Add on your action add_post the next respond with js:
Add on a file on your views
add_post.js.erbwith the next content:For example, you have add a partial
_add_post.html.erbon your views. Now inside this partial you can write your code view:Regards!