PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, May 18, 2022

[FIXED] How to render a partial from another namespace in Rails 3?

 May 18, 2022     partial, ruby-on-rails-3     No comments   

Issue

In my Rails 3 project I have:

namespace :admin do
  resources :users
end

scope :frontend do
  resources :users
end

There is a partial with filename "/views/admin/users/_form_fields.html.haml".

And I want to render it from "/views/frontend/users/_form.html.haml".

This code doesn't work:

render 'admin/users/form_fields', :f => f

Solution

To pass local variables you need this sintax:

render :partial => "/admin/users/form_fields", :locals => { :f => f }

Hope this helps. you can take a look to Rails Guide: Using Partials



Answered By - JCorcuera
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing