Confused about the ways to write code for instance variables

RailsNewbie

I am quite confused on how we write instance variables in Rails.

 Posted by: <%= link_to(@item.user.username, store_path(@item.user)) %>
 Price: <%= number_to_currency @item.price %>

vs

Subject: <%= subject_name @item %>

I am just curious what is the difference between (i) subject_name @item and (ii) @item.price?

Is it not supposed to be @item.subject_name?

spickermann

I would expect that subject_name isn't a variable, but a method. I guess you have a method subject_name defined in one of your helper files that takes an argument - @item in this example.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Confused about send method to set instance variables

From Dev

Confused about Instance variables, creating new objects and methods?

From Dev

Confused about instance initialization

From Dev

Confused about setting environment variables

From Dev

Confused about the following 'generics' code

From Dev

Confused about this php code using curly braces

From Dev

Confused about the big O notation of the code

From Dev

Confused on how to write my code as a function in python

From Dev

Confused about protractor v1.4.0 'protractor' and 'browser' global variables

From Dev

C++ code for copying FILES : : confused about relative address (tilde)

From Dev

Confused about this C code I saw in a job interview

From Dev

Modifying UITableViewCell, where to place this code? Confused about design patterns

From Dev

php: Confused about the way the "use" keyword is used in this code snippet

From Dev

I get confused about two lines source code in express

From Dev

Confused about this C code I saw in a job interview

From Dev

C++ code for copying FILES : : confused about relative address (tilde)

From Dev

Modifying UITableViewCell, where to place this code? Confused about design patterns

From Dev

confused about javascript code "require('./config/passport')(passport);"

From Dev

Confused by the example code which adds new instance methods to types

From Dev

the ways to write lm or glm formula when having a lot of independent variables

From Dev

Different ways of making read public write private variables in swift?

From Dev

I am confused in two ways to create one to many relationship in code first migration . Which one to choose?

From Dev

I do not understand ways of declaring instance variable in the code

From Dev

Function from Data.Map -> Maybe as a class instance. Confused about how to implement

From Dev

Confused about ContentType

From Dev

Confused about lifetime of variable

From Dev

Confused about multiple inheritance

From Dev

Confused about git rebase

From Java

confused about function declaration in { }

Related Related

  1. 1

    Confused about send method to set instance variables

  2. 2

    Confused about Instance variables, creating new objects and methods?

  3. 3

    Confused about instance initialization

  4. 4

    Confused about setting environment variables

  5. 5

    Confused about the following 'generics' code

  6. 6

    Confused about this php code using curly braces

  7. 7

    Confused about the big O notation of the code

  8. 8

    Confused on how to write my code as a function in python

  9. 9

    Confused about protractor v1.4.0 'protractor' and 'browser' global variables

  10. 10

    C++ code for copying FILES : : confused about relative address (tilde)

  11. 11

    Confused about this C code I saw in a job interview

  12. 12

    Modifying UITableViewCell, where to place this code? Confused about design patterns

  13. 13

    php: Confused about the way the "use" keyword is used in this code snippet

  14. 14

    I get confused about two lines source code in express

  15. 15

    Confused about this C code I saw in a job interview

  16. 16

    C++ code for copying FILES : : confused about relative address (tilde)

  17. 17

    Modifying UITableViewCell, where to place this code? Confused about design patterns

  18. 18

    confused about javascript code "require('./config/passport')(passport);"

  19. 19

    Confused by the example code which adds new instance methods to types

  20. 20

    the ways to write lm or glm formula when having a lot of independent variables

  21. 21

    Different ways of making read public write private variables in swift?

  22. 22

    I am confused in two ways to create one to many relationship in code first migration . Which one to choose?

  23. 23

    I do not understand ways of declaring instance variable in the code

  24. 24

    Function from Data.Map -> Maybe as a class instance. Confused about how to implement

  25. 25

    Confused about ContentType

  26. 26

    Confused about lifetime of variable

  27. 27

    Confused about multiple inheritance

  28. 28

    Confused about git rebase

  29. 29

    confused about function declaration in { }

HotTag

Archive