[Rails] Help me connect to MySQL Database

2014-01-20 Thread Nguyen Le
Hi all,
I have one 1 *.html.erb. I want to connect to mySQL and show some
information to website(ff or chrome). Could you help me about that?
Thank you so much

-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/47749480e0a2688da49f8df8032dbd2d%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Rails] Help me connect to MySQL Database

2014-01-20 Thread Colin Law
On 20 January 2014 10:27, Nguyen Le li...@ruby-forum.com wrote:
 Hi all,
 I have one 1 *.html.erb. I want to connect to mySQL and show some
 information to website(ff or chrome). Could you help me about that?

If you want to use Rails then start by working right through a
tutorial such as railstutorial.org, which is free to use online.

Colin

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsTLjSLB4i5M5DEUw08%2Bn37SCo5GYj15PXpKJtxRfOhYA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


[Rails] Re: Help me connect to MySQL Database

2014-01-20 Thread Nguyen Le
Thanks for your reply, Colin. I asked this question, because I want to
make sure file *.html.erb can connect to mySQL database. Could you help
me to answer this question and give me code sample?. Thank you so much

-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/069854e0823d328441f7550a03df0d66%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Rails] Help me connect to MySQL Database

2014-01-20 Thread Walter Lee Davis

On Jan 20, 2014, at 6:06 AM, Nguyen Le wrote:

 Thanks for your reply, Colin. I asked this question, because I want to
 make sure file *.html.erb can connect to mySQL database. Could you help
 me to answer this question and give me code sample?. Thank you so much
 

Colin's reply will help you understand the folly of your question as written. A 
single erb file won't connect to a MySQL database on its own, within the 
context of a Rails application, ever. The View is responsible for showing the 
data, not fetching it or responding to user input.

If you have a full Rails application there, and not just a single erb file, you 
may have a different question. But until you come to grips with the basics of 
how Rails works, I doubt you're going to get much of an answer here that makes 
sense to you until you can formulate your question in another manner.

Walter

 -- 
 Posted via http://www.ruby-forum.com/.
 
 -- 
 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 rubyonrails-talk+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/rubyonrails-talk/069854e0823d328441f7550a03df0d66%40ruby-forum.com.
 For more options, visit https://groups.google.com/groups/opt_out.

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/196D5CB8-FF6B-45F1-A249-8EB51460F8E4%40wdstudio.com.
For more options, visit https://groups.google.com/groups/opt_out.


[Rails] Re: Help me connect to MySQL Database

2014-01-20 Thread jsnark
*.erb files do not connect to databases.  Models do.  Follow Colin's advise 
and work through the tutorial.

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/a0ba9a1e-4418-4801-81b7-53eba13ac66e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Rails] Re: Help me connect to MySQL Database

2014-01-20 Thread Jordon Bedwell
On Mon, Jan 20, 2014 at 8:10 AM, jsnark s...@monmouth.com 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.

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAM5XQnxRjd-3PptBrJyY_rYgnfyDjR57cnQg2GJKageYNLjgCA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Rails] [Question] Is there any way to define class_name dynamically in has_many relation ?

2014-01-20 Thread Takashi Nakagawa
Hi walter, thanks for answering question.

I've read about polymorphic relationships and I've tried it before, but in 
my case, I should use database which is already used in other project and I 
make new rails app with the database. so I can' t change database structure 
easily. 

2014年1月17日金曜日 23時25分24秒 UTC+9 Walter Lee Davis:

 Have you read anything about polymorphic relationships yet? That's a good 
 place to start. Rails Guides, ActiveRecord Relations, read the whole page, 
 but pay attention to the section on Polymorphism. 

 Walter 

 On Jan 17, 2014, at 4:55 AM, Takashi Nakagawa wrote: 

  
  
  -- 
  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 rubyonrails-ta...@googlegroups.com javascript:. 
  To post to this group, send email to 
  rubyonra...@googlegroups.comjavascript:. 

  To view this discussion on the web visit 
 https://groups.google.com/d/msgid/rubyonrails-talk/ecc2d9dd-fb18-4248-a50c-4fa9c36721b1%40googlegroups.com.
  

  For more options, visit https://groups.google.com/groups/opt_out. 



-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/6e224b17-820d-451e-be23-96b70cbeabf6%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Rails] [Question] Is there any way to define class_name dynamically in has_many relation ?

2014-01-20 Thread Walter Lee Davis

On Jan 20, 2014, at 9:43 AM, Takashi Nakagawa wrote:

 Hi walter, thanks for answering question.
 
 I've read about polymorphic relationships and I've tried it before, but in my 
 case, I should use database which is already used in other project and I make 
 new rails app with the database. so I can' t change database structure 
 easily. 

Okay, well there are ways to change Rails' opinionated conventions about 
table naming and model naming. Have a look at the Rails Guides, I don't have 
time to look it up for you, but I know it's in there. 

The only reason I can think of to not do what I recommend here is if you really 
really actually need some particular database feature to actually make your 
application work. Rails is mightily database-agnostic, but only if you don't 
need those features. If you do, then you really will find yourself fighting the 
conventions of the framework every step of the way.

What I recommend you do is clear off a section of whiteboard and write up a 
concordance between your existing table names and the models you want to 
create. So if you have a model named Person, which would want its table to be 
named people, yet your DBA insisted on naming that one ApplicationUsers or 
whatever, just draw a big circle and put both names in it. Continue until the 
*logical* structure of your Rails app is mapped out according to what you want 
to call your object (which drives the URL structure among other things).

Build your app using a different database -- maybe just a SQLite db -- with all 
of the tables named the way Rails expects them to be, for speed and flexibility 
(use migrations). Be sure to write your tests, and get things working the way 
you want the app to look. Then go back to your whiteboard, and your model 
files, and add the line of code that re-defines the table name (and primary 
key, if it isn't named id, or foreign key, if it isn't named 
singular_underscored_model_name_id) for each of your relationships. Change the 
database over, and see if it still works. Test and patch until it does.

Walter

 
 2014年1月17日金曜日 23時25分24秒 UTC+9 Walter Lee Davis:
 Have you read anything about polymorphic relationships yet? That's a good 
 place to start. Rails Guides, ActiveRecord Relations, read the whole page, 
 but pay attention to the section on Polymorphism. 
 
 Walter 
 
 On Jan 17, 2014, at 4:55 AM, Takashi Nakagawa wrote: 
 
  
  
  -- 
  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 rubyonrails-ta...@googlegroups.com. 
  To post to this group, send email to rubyonra...@googlegroups.com. 
  To view this discussion on the web visit 
  https://groups.google.com/d/msgid/rubyonrails-talk/ecc2d9dd-fb18-4248-a50c-4fa9c36721b1%40googlegroups.com.
   
  For more options, visit https://groups.google.com/groups/opt_out. 
 
 
 -- 
 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 rubyonrails-talk+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/rubyonrails-talk/6e224b17-820d-451e-be23-96b70cbeabf6%40googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/37EAC3A5-073A-41CA-933A-C822AD29974A%40wdstudio.com.
For more options, visit https://groups.google.com/groups/opt_out.


[Rails] Re: Help me connect to MySQL Database

2014-01-20 Thread Nguyen Le
The first, I want to say thank to all reply. I think it is very helpful
for me. I will learn Rails step by step. Thank you so much.

Nguyen

-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/7d510dae8fa092f0c66700b68fafd96c%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.


[Rails] Re: Help me connect to MySQL Database

2014-01-20 Thread Lehner Viktor
Hi,

This Video helped for 
me: 
http://www.youtube.com/playlist?list=PLcwklDOKWhc-4SOfwx71yEKzMHGw1BU_hfeature=c4-feed-u

2014. január 20., hétfő 11:27:36 UTC+1 időpontban Ruby-Forum.com User a 
következőt írta:

 Hi all, 
 I have one 1 *.html.erb. I want to connect to mySQL and show some 
 information to website(ff or chrome). Could you help me about that? 
 Thank you so much 

 -- 
 Posted via http://www.ruby-forum.com/. 


-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/d5627177-8e4c-4f11-babd-46b0baec0842%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[Rails] [JOBS] Praktikanten im Ruby on Rails Development (m/w), Hannover, Germany

2014-01-20 Thread Jan Erichsen


Für die Unterstützung und Bereicherung unseres Web Development Teams suchen 
wir einen motivierten: 
Praktikanten im Ruby on Rails Development (m/w) 

für einen Zeitraum ab mindestens 3 Monaten, mit der Option auf Übernahme 
nach erfolgreicher Praktikumszeit. 

 

*I WORK BECAUSE I LOVE THIS SHIT!* 

Wir entwickeln innovative und großartige Software am Puls der Zeit!
Neben unseren eigenen Produkten unterstützen wir auch Kunden bei eigenen 
Projekten mit unserer Erfahrung und unserem Können!  

Bei uns erwarten dich spannende, anspruchsvollen und herausfordernde 
Aufgaben, mit der täglich Chance dich in flachen Hierarchien und einem 
lebendigen Umfeld weiterzuentwickeln.

Neben tollen und abwechslungsreichen Aufgaben, schönen Büros, Platz für 
eigene Ideen, haben wir auch noch ein großartiges Team das mit Einsatz, 
Freude und Können den neuen digitalen Herausforderungen begegnet.

*Dein Profil:*

   - Gute Kenntnisse in der Programmiersprache Ruby
   - Gute Kenntnisse des Rails-Frameworks
   - Kenntnisse in HTML, CSS und Javascript wünschenswert
   - Vorliebe für sauberen, objektorientierten Code und die Nutzung von 
   Design Patterns

  

*Deine Aufgaben:*

   - Unterstützung in der Entwicklung und technische Konzeption von 
   Webseiten und deren Backend
   - Unterstützung in der Entwicklung innovativer, kleiner und großer 
   Webanwendungen

 

*Um dir einen ersten Eindruck zu vermitteln, hier ein paar Punkte und 
Vorteile die den Job ausmachen*

   - Spannende Projekte und Aufgaben, viel Abwechslung und Dynamik
   - Namhafte nationale und internationale Kunden aus verschiedenen Branchen
   - Offenheit für neue Ideen und Arbeitsweisen
   - Eigenverantwortung und Entwicklungsmöglichkeiten
   - Neuste digitale Spielereien wie Oculus Rift, 3D Drucker und Arduino
   - Tolle Kollegen und Rückhalt in einem motivierten und erfahrenen Team
   - Mitarbeiteraktivitäten wie z.B. Badminton, Filmabende und gemeinsame 
   Veranstaltungen
   - Und genügend Clubmate

  

*Möchtest du uns unterstützen?*

Auch wenn du glaubst, dich nicht zu 100% in dieser Stellenausschreibung 
wiederzufinden, gib uns trotzdem die Möglichkeit dich kennenzulernen. Wir 
sind auf der Suche nach dem Typ Mensch, der zu uns passt und nicht nur nach 
einem Profil.

*Wir freuen uns auf deine Bewerbung!*

Bitte sende deine Bewerbung am besten als PDF mit frühestem Eintrittstermin 
und deiner Gehaltsvorstellung an: jobs(at)thisisdmg.com j...@thisisdmg.com


www.thisisdmg.com

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/cb28fa7c-147c-44f3-a882-e8bc4dd0f499%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[Rails] [JOBS] Ruby on Rails Developer (m/w), Hannover, Germany

2014-01-20 Thread Jan Erichsen


Für die Unterstützung und Bereicherung unseres Web Development Teams suchen 
wir einen motivierten: 
Ruby on Rails Developer (m/w) 

 

*I WORK BECAUSE I LOVE THIS SHIT!* 

Wir entwickeln innovative und großartige Software am Puls der Zeit!
Neben unseren eigenen Produkten unterstützen wir auch Kunden bei eigenen 
Projekten mit unserer Erfahrung und unserem Können!  

Bei uns erwarten dich spannende, anspruchsvollen und herausfordernde 
Aufgaben, mit der täglich Chance dich in flachen Hierarchien und einem 
lebendigen Umfeld weiterzuentwickeln.

Neben tollen und abwechslungsreichen Aufgaben, schönen Büros, Platz für 
eigene Ideen, haben wir auch noch ein großartiges Team das mit Einsatz, 
Freude und Können den neuen digitalen Herausforderungen begegnet.

*Dein Profil:*

   - Sehr gute Kenntnisse in der Programmiersprache Ruby
   - Sehr gute Kenntnisse des Rails-Frameworks
   - Gute Kenntnisse in HTML, CSS und Javascript wünschenswert
   - Vorliebe für sauberen, objektorientierten Code und die Nutzung von 
   Design Patterns
   - Abgeschlossenes Studium der Informatik oder vergleichbare Qualifikation

  

*Deine Aufgaben:*

   - Entwicklung und technische Konzeption von komplexen Backend-Systemen 
   und deren Webseiten
   - Entwicklung innovativer Webanwendungen

 

*Um dir einen ersten Eindruck zu vermitteln, hier ein paar Punkte und 
Vorteile die den Job ausmachen*

   - Spannende Projekte und Aufgaben, viel Abwechslung und Dynamik
   - Namhafte nationale und internationale Kunden aus verschiedenen Branchen
   - Offenheit für neue Ideen und Arbeitsweisen
   - Eigenverantwortung und Entwicklungsmöglichkeiten
   - Neuste digitale Spielereien wie Oculus Rift, 3D Drucker und Arduino
   - Tolle Kollegen und Rückhalt in einem motivierten und erfahrenen Team
   - Mitarbeiteraktivitäten wie z.B. Badminton, Filmabende und gemeinsame 
   Veranstaltungen
   - Und genügend Clubmate

  

*Möchtest du uns unterstützen?*

Auch wenn du glaubst, dich nicht zu 100% in dieser Stellenausschreibung 
wiederzufinden, gib uns trotzdem die Möglichkeit dich kennenzulernen. Wir 
sind auf der Suche nach dem Typ Mensch, der zu uns passt und nicht nur nach 
einem Profil.

*Wir freuen uns auf deine Bewerbung!*

Bitte sende deine Bewerbung am besten als PDF mit frühestem Eintrittstermin 
und deiner Gehaltsvorstellung an: jobs(at)thisisdmg.com j...@thisisdmg.com

www.thisisdmg.com


j...@thisisdmg.com

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/53126309-0389-44db-bebf-a794954822e9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[Rails] Locale in link_to doesn't work

2014-01-20 Thread Guilherme Oderdenge
My problem is described here: 
http://stackoverflow.com/questions/21238344/locale-in-link-to-doesnt-work?noredirect=1#comment31993079_21238344

Any ideas?

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/300f76a3-53c0-4565-91ca-28ea6e6caede%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[Rails] Why Does def some_func=(obj) Behave This Way?

2014-01-20 Thread Peter
Hello Everyone,

Why does this function behave this way?

class Confuse
   def confusion=(obj)
 @obj = obj
 return 'expected answer'
   end
 end
 c = Confuse.new 

c.confusion = 'this should be wrong' 

 
This returns 'this should be wrong'.

I am reading *Programming Ruby 1.9  2.0* by Dave Thomas with Chad Fowler 
and Andy Hunt. This problem was mentioned in page 129, but their 
explanation did not really make sense.

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/85c3011c-787a-4894-bfe9-3add77d59925%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Rails] Why Does def some_func=(obj) Behave This Way?

2014-01-20 Thread Jordon Bedwell
On Mon, Jan 20, 2014 at 1:30 PM, Peter pe...@poproj.com wrote:
 class Confuse
   def confusion=(obj)
 @obj = obj
 return 'expected answer'
   end
 end
 c = Confuse.new

 c.confusion = 'this should be wrong'


 This returns 'this should be wrong'.

Ruby setters always ignore your explicit return and the last line as a
return and return the attribute given it... as a feature, and this
should be expected behavior as all Ruby setters behave this way.

This means that you define :hello= and it accepts the attribute :world
and you give :world the value of foo it will return foo because
that was the value it was given for it's assignment and logically that
is the value it should return if it returns anything at all.  To
return expected answer would be ambiguous no matter how you try to
play it.

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAM5XQnwVQFYdctcLf_XLZup4MxFdQV-0gn41c1y5on8tWoo%2BRQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Rails] Re: Help me connect to MySQL Database

2014-01-20 Thread jsnark


On Monday, January 20, 2014 9:23:10 AM UTC-5, Jordon Bedwell wrote:

 On Mon, Jan 20, 2014 at 8:10 AM, jsnark s...@monmouth.com 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 rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
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.


Re: [Rails] Re: Help me connect to MySQL Database

2014-01-20 Thread Jordon Bedwell
On Mon, Jan 20, 2014 at 2:45 PM, jsnark s...@monmouth.com wrote:


 On Monday, January 20, 2014 9:23:10 AM UTC-5, Jordon Bedwell wrote:

 On Mon, Jan 20, 2014 at 8:10 AM, jsnark s...@monmouth.com 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:

Sure it does, if by direct you mean has to go through a client library.


 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).

If we throw out the method and apply what the method does then:
Sure I do, unless... I go ***through*** the same library that ActiveRecord does.

 Views (*.erb files)
 should never directly reference models.  They get their database information
 from the controller.

Sure they shouldn't because `@user = User.where(:id = session[:uid])`
in the controller isn't how most programmers go about it, most of them
decorate it all into neat and tidy formatted objects that create
completely indirect access.  An instance of an object in a variable
set inside of the controller and accessible in the view is not an
indirect access.  But maybe you meant to say you should never
initialize that object in the view as it's the views job to transform
that object into something meaningful not to pull that data into that
object and all the other things we go on about.

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAM5XQnyhN5b6wj4oda-T1g%2Bz%3DTh2Xx1ANpj-Aqt24LWdBJ89KQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


[Rails] capistrano deploy issue: rails (= 4.0.0) depends on bundler ( 2.0, = 1.3.0)

2014-01-20 Thread saravanan p
Hi all,

I am trying to push rails 4 app into my server using capistrano.

i am getting following error while 'cap deploy',

  * executing cd -- projects/testproject/releases/20140121061131  
RAILS_ENV=production RAILS_GROUPS=assets rake assets:precompile
servers: [xxx]
[xxx] executing command
*** [err :: xxx] rake aborted!
*** [err :: xxx] 
*** [err :: xxx] Bundler could not find compatible versions for gem 
bundler:
*** [err :: xxx] In Gemfile:
*** [err :: xxx] rails (= 4.0.0) depends on
*** [err :: xxx] bundler ( 2.0, = 1.3.0)
*** [err :: xxx] 
*** [err :: xxx] Current Bundler version:
*** [err :: xxx] bundler (1.0.15)
*** [err :: xxx] 
*** [err :: xxx] (See full trace by running task with --trace)
*** [err :: xxx] 
command finished in 541ms
*** [deploy:update_code] rolling back


but in both local and server i have bundler version 1.5.0 
Can anyone help me?

My deploy.rb file:

require 'capistrano/ext/multistage'
#require 'bundler/capistrano'

set :stages, [development, production]
set :default_stage, development

set :application, testproject

set :scm, git
set :repository,  path_to_my_project_repo_xx

set(:deploy_to) { /home//projects/#{application} }

set :user, username
set :password, password

set :deploy_via, :copy
set :branch, master
set :keep_releases, 5

set :use_sudo, false
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, 
`subversion` or `none`

role :web, x  # Your HTTP server, 
Apache/etc
role :app, x  # This may be the same as 
your `Web` server
role :db,  x, :primary = true # This is where Rails migrations 
will run


after deploy, deploy:symlink_config_files

namespace :deploy do
  desc Symlink shared config files
  task :symlink_config_files, :roles = [:app] do
run ln -nfs #{deploy_to}/#{shared_dir}/config/database.yml 
#{release_path}/config/database.yml
run if [ -d #{release_path}/tmp ]; then rm -rf #{release_path}/tmp; 
fi; ln -nfs #{deploy_to}/#{shared_dir}/tmp #{release_path}/tmp
  end
end

My Gemfile:

source 'https://rubygems.org'
gem 'rails', '4.0.0'
gem 'mysql2'
gem 'magic_multi_connections'
gem 'execjs'
gem 'therubyracer', :platforms = :ruby
gem 'sass-rails', '~ 4.0.0'
gem 'uglifier', '= 1.3.0'
#gem 'capistrano', '~ 2.15'
group :development do
gem 'capistrano', '~ 2.15'
end
gem 'coffee-rails', '~ 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~ 1.2'
group :doc do
  gem 'sdoc'#, require: false
end
gem 'bcrypt-ruby', '~ 3.0.0'


Regards
Saravanan P

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/bec152cc-c552-4034-b068-76c273033d71%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Rails] capistrano deploy issue: rails (= 4.0.0) depends on bundler ( 2.0, = 1.3.0)

2014-01-20 Thread Jordon Bedwell
On Tue, Jan 21, 2014 at 12:33 AM, saravanan p
psaravanan11.ra...@gmail.com wrote:
 Hi all,

 I am trying to push rails 4 app into my server using capistrano.

 i am getting following error while 'cap deploy',

   * executing cd -- projects/testproject/releases/20140121061131 
 RAILS_ENV=production RAILS_GROUPS=assets rake assets:precompile
 servers: [xxx]
 [xxx] executing command
 *** [err :: xxx] rake aborted!
 *** [err :: xxx]
 *** [err :: xxx] Bundler could not find compatible versions for gem
 bundler:
 *** [err :: xxx] In Gemfile:
 *** [err :: xxx] rails (= 4.0.0) depends on
 *** [err :: xxx] bundler ( 2.0, = 1.3.0)
 *** [err :: xxx]
 *** [err :: xxx] Current Bundler version:
 *** [err :: xxx] bundler (1.0.15)
 *** [err :: xxx]
 *** [err :: xxx] (See full trace by running task with --trace)
 *** [err :: xxx]
 command finished in 541ms
 *** [deploy:update_code] rolling back


 but in both local and server i have bundler version 1.5.0
 Can anyone help me?

Some where on the server there is /not/ bundler 1.5.0 because it's
showing that it has access to bundler 1.0.15.  I would first try to
login to the server and gem update (since most of the time bundler is
the only gem aside from the set of default gems that is setup in gem)
and then gem clean and try a fresh deploy.

-- 
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 rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAM5XQnzSiSi4ZMbWFP%2Bd7i4%2Bup8O6zm67b5X7y8LurcWayKMhA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.