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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:50:03+00:00 2026-06-12T18:50:03+00:00

I am new to ruby and a total noob in rails. My head is

  • 0

I am new to ruby and a total noob in rails. My head is spinning with octothorps and cucumber and BDD after reading Michael Hartl’s tutorial.

I have experience in server side development using Archaic Java and ugly jsp/servlets. I wanna be cool and learn rails.

Need help understanding basic Rails Concepts, even after reading the book, it just doesn’t click:

  1. I thought I knew how to use the darn instance variables across the Models, views and controllers, but when I use them things don’t work. I need the rules for where I can use them, when and how. I kinda get how to use instance variables from the controller to the view. But Model to controller? – Clueless.
  2. Methods in the model, why do they need to be methods? Can i just create variables and use them in my controllers and views? How does that part work.
  3. um, sort of like the first question.. Variable usage in models and controllers … ??
  • 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-12T18:50:04+00:00Added an answer on June 12, 2026 at 6:50 pm

    The first thing to remember, before we even get into your questions, is that all variables, regardless of scope, are only active for the current request. You can use config values for persistence, but a global will expire at the end of a request, same as an instance variable.

    1. Instance variables that are set in the controller are available to the view. Models only have access to variables that have been directly passed to the Class or instance. This means that if you have a @first_name variable, in your controller or view, you won’t be able to see it in your model. If you wanted to use it in your model, you would have to do something like MyModelName.new( :first_name => @first_name ) or an_instance_of_my_modelname.some_method_i_have_added( @first_name ).

    2. They don’t have to be methods, per se, but they almost certainly will end up being methods. Your most typical use of “variables” in a model would be the attributes. Attributes on a model are available to the instance of the model, regardless or whether it is in the view, controller, helper, or where ever. Attributes work by basically defining a setter and a getter method, behind the scenes (an attribute of first_name would make method first_name() and first_name=()). These methods can even be overridden in the model, to manipulate the values prior to insertion or removal from the database. You can achieve a similar effect without the database, using http://apidock.com/ruby/Module/attr_accessor. Class methods are the same in scope, but operate on the Class, rather than a specific instance.

    3. Sorta the same as the answers for 1 and 2… 😉 Variables (but not constants) set in models must be exposed via a method to be available in the controllers and views. Nothing can be seen from a model that was not supplied explicitly. Otherwise, between the views, controllers, helpers, and whatnot, pretty much anything with an @ (or @@) in front of it is visible, and any variables without are not.

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

Sidebar

Related Questions

total noob to rails and am using the Hartl tutorial. Got to chapter 4
I'm currently evaluating options for adding sub-domain support to a new Ruby on Rails
new on ruby and using windows xp and rails 3, i want to send
I'm brand new to ruby and rails and I'm having trouble creating a sign-out
I'm new to Ruby and I'm writing a pure Ruby script, not Rails. This
This loop does not terminate after I type x. I'm really new to Ruby,
I'm new to Rails (and ruby). What is the standard way of iterating through
I'm currently finishing up testing a new Ruby on Rails app. Just recently, some
I'm a new Ruby/Rails guy. Here's one question puzzling me: Can we find the
I have a new Ruby on Rails installation where I can see the default

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.