Created
January 27, 2012 04:14
-
-
Save anonymous/1686947 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
| def create | |
| @device = Device.new(params[:device]) | |
| @device.user = current_user | |
| # the respond to structure allows ajax to run | |
| # but falls back to normal html form processing if | |
| # javascript is disabled, I think | |
| @save_status = false | |
| @rendered_content = "" | |
| if @device.save | |
| @save_status = true | |
| @rendered_content = render_to_string(:action => :show, :layout => false) | |
| else | |
| @rendered_content = render_to_string(:action => :new, :layout => false) | |
| end | |
| binding.pry | |
| respond_to do |format| | |
| format.html { | |
| if @save_status | |
| render 'show' | |
| else | |
| render 'new' | |
| end | |
| } | |
| format.js # this will render the | |
| end #respond_to | |
| end #create | |
| #create.js.erb | |
| /* render the form response */ | |
| $('#content').html(Utility.htmlDecode("<%= escape_javascript(@rendered_content) %>")); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment