Monday, June 27, 2011

[Rails] serving only controller+action specific css/javascript

Hi, input please!

I'm trying to dynamically serve js/css based on the active controller+action, e.g.:

    <link href="/stylesheets/people/update.css" /> 
    <script src="/javascripts/people/update.js"></script> 

In application_helper.rb, I'm using the following method to create the dynamic bits of the asset URLs:

    def asset_path_fragment
      "#{controller.controller_name}/#{controller.action_name}"
    end

Then I realized a flaw in my logic:

  def update
    if @something_goes_wrong
      render :edit # render the #edit's view but erroneously serve the #update's css/js
    end
  end
  
So ... what should I do?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/0bMHqe-I96QJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate