Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8397379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:46:25+00:00 2026-06-09T20:46:25+00:00

In order to not repeat myself, I would like to create a function that

  • 0

In order to not repeat myself, I would like to create a function that render a form block (text field or text area) in a specific way. I want a result like this one (using Haml, and twitter-bootstrap):

.form-block.input-prepend
    %span.add-on>
        %i.icon.icon-home
    = f.text_field :name, :value => @store.name, :placeholder => 'Company Name'

To do that, I created a file views/layouts/_form-block.html.haml where I inserted the following code:

.form-block.input-prepend
    %span.add-on>
        %i{ :class => "icon icon-#{icon}" }
    = yield

And I call the block in my view using:

- render :template => 'layouts/_form-block', :locals => { :icon => 'home' } do
    = f.text_field :name, :value => @store.name, :placeholder => 'Company Name'

But It doesn’t work. I have the following error 'nil' is not an ActiveModel-compatible object that returns a valid partial path.

Do you have any idea? Is this the best way to do?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:46:27+00:00Added an answer on June 9, 2026 at 8:46 pm

    If you want to use = yield to pass a block, you need to render as a layout. Use render :layout => instead of render :template =>.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to make a number generator that does not repeat the number it
I have a base method that I'm writing in order to not repeat the
As you know, WSASend-completion-WSASend-...(repeat) guarantees sending data in order. However, I heard that WSASend-WSASend-WSASend-completion-completion-completion
Problem: I want to list n number of games from each genre (order not
I am using Autofac to handle dependency injection in my application. In order not
Here's the HTML I'm trying to use: <h1>Order Not Paid<span class=not-paid></span></h1> Of course if
Hi Order By not working on MySql the code is as follows, select *
According to the Puppet documentation: Order does not matter in a declarative language. If
I'm look to naturally sort an array, in reverse order and not preserve the
Order by descending is not working on LINQ to Entity In the following Query

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.