Created
October 8, 2010 18:01
-
-
Save twinge/617227 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## _form.html.erb ## | |
<%= link_to(image_tag(element.element_data.url(:thumb)), portfolio_add_element_path(element), :remote=>true) %> | |
## Portfolios_Controller.rb ## | |
respond_to :js, :html | |
def add_element | |
@portfolio = Portfolio.find(portfolio_id) | |
@element = Element.find(element_id) | |
@portfolio.elements.create(@element) | |
respond_with(@portfolio) do |format| | |
# You don't want to redirect when you come from an ajax call. | |
format.html { redirect_to (@portfolio) } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment