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 6159005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:03:27+00:00 2026-05-23T21:03:27+00:00

If I have a model named Client and controller that looks like this class

  • 0

If I have a model named Client and controller that looks like this

class ClientController < ApplicationController
def new
  @client = Client.new
  @client.name = "New Guy"
end
end

and I am using HAML, what will my view need to look like to render a form based on this.

I have this

%p= @client.name
-form_for :client, @client do |c|
 c.label :c.name
 c.text_field :c.name

but my html ends up looking like this

<p>New Guy</p>
<form accept-charset="UTF-8" action="/client/new" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="authenticity_token" type="hidden" value="orGtE1V05QIaye5kSsAi5SBdEAV0AJX9uZYUzHw5P64=" /></div>
  c.label :c.name
  c.text_field :c.name
</form>

Update:
Thanks for the answers. when I change the view to

%p= @client.name
-form_for :client, @client do |c|
  = c.label :c.name
  = c.text_field :c.name 

I get the following error

undefined method `name' for :c:Symbol

Extracted source (around line #3):

1: %p= @client.name
2: -form_for :client, @client do |c|
3:   = c.label :c.name
4:   = c.text_field :c.name

If I comment out lines 2,3, and 4 The name prints out fine. What am I missing?

Update 2:

If I change the view to

%p= @client.name
-form_for :client, @client do |c|
 c.label :name
 c.text_field :name

no more error. Thanks.

  • 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-05-23T21:03:30+00:00Added an answer on May 23, 2026 at 9:03 pm

    You need to use = before the ruby function calls, so that they’re evaluated.

    %p= @client.name
    -form_for :client, @client do |c|
      = c.label :c.name
      = c.text_field :c.name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Client and ProposalRequest model that look like this: class Client <
I have a such model named Foo: class Foo(models.Model): name = models.CharField() entry =
I have one grails application.In that I have one model class named Book. From
I'm using grid that looks like that: Html.Telerik().Grid(Model).Name(preciousGrid). ... bla bla bla.. .ClientEvents(events =>
I have two tables: Client(id,name,...) Purchase(id,item,date,client_id,...) They have their respective Model, with their validations.
Let's say I have this model named Product with a field named brand .
I have a controller/model hypothetically named Pets. Pets has the following declarations: belongs_to :owner
I have a model name called StoreEntry. Django admin changes it to look like
I have the following model and instance: class Bashable(models.Model): name = models.CharField(max_length=100) >>> foo
I'm on Rails 3. I have a model Client that has an address_id .

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.