mysql - SQL Joins in Rails -


Below is trying to work in the existing database in the Rails, MySQL works very well in the console:

  Select the title, add blog_name from exp_weblog_titles, exp_weblog_titles.weblog_id = exp_weblogs.weblog_id LIMIT on exp_weblogs; + ------------ + --------------- + | Title | Blog_name | + ------------ + --------------- + | What do we do Chicago_Pages | + ------------ + --------------- + 1 line set (0.00 seconds)  

Although rail In the console, this is what I get:

  & gt; @title = title.find_b_sql ("select title, exp_weblog_titles from blog_name exp_weblog_titles.weblog_id add exp_weblogs" exp_weblogs.weblog_id LIMIT 1 ") => [# & lt; title title:" what do we do "gt; ]  

I have indicated to the fact that for some reason the Railways will display columns only from the first table in console mode without any tricks Can anyone tell me how to connect ?

says responsible However, I guess what you want:

  class title & lt; ActiveRecord :: base is_to: weblog and class weblogs & lt; ActiveRecord :: base has_many: title end  

You can get the title attributes of the weblog by doing

  @weblog = Weblog.find (...) @ Webglog.title.attributes  

and on the other side

  @titles = Title.find_all @titles [0] .weblog.attributes  

hope That


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -