How do I render a partial without having to supply the "_" in front of the file name? Is there a parameter I can call to not use it?
This problem popped up using RABL and Backbone - using RABL requires me to have a file in my views like "index.json.rabl". But, when I use embed the JSON right on the page load (as is usual with Backbone), I'm required to call the file "_index.json.rabl". These 2 files are the exact same thing, just required to have different names. I'm looking to use just 1 file, "index.json.rabl" and force the render() function to look for that file name, without the "_".
=> EDIT
The standard solutions that people have described below don't work. It's likely a RABL issue then? The below code always goes to the views/countries/_index.json.rabl file.
In my .erb file
countryList.reset(<%=get_json("countries", "index", @countries)%>);
In my application_helper.rb file
def get_json(view_path, view_action, object)
path = view_path + '/' + view_action + ".json"
return raw(render(path, object: object, :formats => [:rabl]))
end
You can render a file by doing the following:
render :file => "filename"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With