I am working on a rails/angular application where all of the front end
is angular and the angular controllers call rails controller actions.
The idea is to be able to include this application on third party web
sites, not necessarily ours. So, what I’m trying to do is have a script
tag pointing to a rails controller action which returns all of the
scripts concatenated that are in the application.js file. I have the
following file in my public directory…
And then in my controller, I have this action.
def board
api_key = params[:api_key]
board = nil
unless api_key.nil?
board = Board.where(‘api_key=? and active=?’, api_key, true)
end
respond_to do |format|
if !board.any?
format.js { render inline: ‘invalid call’, status: 403 }
else
cookies[:board_id] = board.first().id
format.js
end
end
end
So, I have successfully returned the board.js.erb file associated with
this action, but instead I want to return the concatenated and minified
scripts from application.js. My understanding of the asset pipeline is
that when pushed to production, rails will already concat and minify the
application.js files into one js file. But how can I do something like
that directly from the controller action? Thanks.