Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering a partial #26

Open
PragTob opened this issue Jun 15, 2015 · 4 comments
Open

Rendering a partial #26

PragTob opened this issue Jun 15, 2015 · 4 comments

Comments

@PragTob
Copy link

PragTob commented Jun 15, 2015

Hi there,

thanks for your work!

I'd like it to be possible to render a partial easily through just render my_object - which then calls to_partial_path sets the right locals and renders it.

When I try it, I get an error because it tries to name space it as render_anywhere which of course does not work, e.g.:

ActionView::MissingTemplate: Missing partial render_anywhere/cover_pages/_cover_page with {:locale=>[:en], :formats=>[:html, :text, :js, :css, :ics, :csv, :vcf, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :haml, :jbuilder]}. Searched in:

Maybe it's already possible and I'm just missing something.

Thank you!
Tobi

@michaelachrisco
Copy link

I was able to get partials working using something like:
render :partial => "#{role}/user/user_links"
but when I try to set a local variable:

    render :partial => "#{role}/user/user_links",
               :locals => { :user => user }

I get a

ActionView::Template::Error:
       wrong number of arguments (0 for 1..2)

@PragTob
Copy link
Author

PragTob commented Jul 24, 2015

I think I fixed it in the meantime by defining my own controller in my own namespace... I'm off the project now though :)

@ghost
Copy link

ghost commented Nov 14, 2016

I'm having a similar issue on Rails 4.

Partials referenced from the template are being resolved to render_anywhere/rendering/_{#template_name}.erb. Is there any way to resolve them to the same directory as the template doing the rendering?

@Tashows
Copy link

Tashows commented Oct 2, 2018

I had the same issue, mainly concerning polymorphic records rendering. Solved it like this:
render partial: "#{polymorphicable.class.table_name.to_s}/#{polymorphicable.class.to_s.underscore}}", locals: {polymorphicable.class.to_s.underscore.to_sym => polymorphicable}
It's not as clean as before, but works for me. It would be great if we don't have to do this in the future though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants