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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:52:13+00:00 2026-05-18T10:52:13+00:00

First of all, I realize I should have tried to fully grasp Ruby before

  • 0

First of all, I realize I should have tried to fully grasp Ruby before jumping into Rails. However, nothing in Ruby seemed too difficult to quickly grasp (until this!), so I decided to get started while I was still enthusiastic about learning. ,__,

Anyway, here is a super-condensed example of form_for:

<%= form_for(@post) do |f| %>
    <div class="field">
        <%= f.label :name %><br />
        <%= f.text_field :name %>
    </div>
<% end %>

I understand that methods in Ruby need not be called with parenthesis. However, form_for is being called with parenthesis, and yet somehow, it seems as though the do |f| block is being passed to it!

Is form_for returning a method that takes a block, and then is that method immediately being called (without parenthesis) by passing the do |f| block? What’s going on here?

  • 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-18T10:52:13+00:00Added an answer on May 18, 2026 at 10:52 am

    Ruby uses a lot of what is called ‘syntactic sugar’ in that it is a bit more flexible than other languages in how certain operations are interpreted.

    for instance:

    model.property = "something"
    

    is actually a function call:

    model.property=("something")
    

    your form_for example is a similar case. Blocks are silently passed into Ruby functions as a parameter.

    my_block = Proc.new { some code }
    my_function(param1, param2, &my_block)
    

    is equivalent to

    my_function param1, param2 do
      some code
    end
    

    and in the function def for my_function you could write:

    def my_function(param1, param2, &block)
    

    and you could access the block via the parameter, as well as yield.

    So when you use block syntax, it’s interpreted as a parameter, but it’s really not.

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

Sidebar

Related Questions

First of all, what's the difference between: www.domain.com and domain.com Should I pay attention
First of all, excuse my poor topic title. I simply have no idea how
First of all, before I begin, I am using VC++ 2008 professional, running an
I have a requirement where users should be able to navigate from the first
first of all, sorry if that question is dumb but I´m a total newbie
First of all, I'm really new to the MVC Asp.Net ideology. I would like
First of all, I'm not sure if the title accurately describes what I'm referring
First of all, I found this: Objective C HTML escape/unescape , but it doesn't
First of all, for the sake of clarity: the question is addressed to those
First of all, I'm using Windows, just to make that clear. I am using

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.