On Monday, January 20, 2014 9:23:10 AM UTC-5, Jordon Bedwell wrote:
>
> On Mon, Jan 20, 2014 at 8:10 AM, jsnark <[email protected] <javascript:>> 
> wrote: 
> > *.erb files do not connect to databases.  Models do.  Follow Colin's 
> advise 
> > and work through the tutorial. 
>
> If *.erb files don't connect  to the database in the entire context of 
> the application (which they do through models which does it through 
> other stuff) then you are wrong too, because models don't connect to 
> the database, they go through other stuff (like your view does) and 
> model out the behavior. 
>

No, you are wrong.  The model xyz.rb has direct access (through 
inheritance) to the database table xyzs.  Thus, the method:

def Xyx.get_first
  find(1)
end

returns the row of table xyzs with id=1 with no qualification.  In a 
controller, the statement find(1) is meaningless.  You have to reference 
the model to get access to the table as in Xyz.find(1).  Views (*.erb 
files) should never directly reference models.  They get their database 
information from the controller.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/5f080486-92c1-4a60-b157-02e6ddb11d0a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to