Skip to content

Instantly share code, notes, and snippets.

@saulius
Created December 20, 2009 14:19
Show Gist options
  • Save saulius/260499 to your computer and use it in GitHub Desktop.
Save saulius/260499 to your computer and use it in GitHub Desktop.
module ApplicationHelper
def javascript_parameters
params = { :csrf_token => form_authenticity_token }
if defined? collection
params.update(:resource => { :new => new_resource_url, :collection => collection_url })
else
if defined? resource
if resource.new_record?
params.update(:resource => { :new => new_resource_url, :collection => collection_url })
else
params.update(:resource => { :show => resource_url, :new => new_resource_url, :edit => edit_resource_url, :collection => collection_url })
end
end
end
if defined? current_user and not(current_user.nil?)
params.update(:user => { :id => current_user.id, :show_nsfw => current_user.show_nsfw, :show_content => current_user.show_content } )
end
params.to_json
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment