Hi there Yes, I know very little of ruby. I must take a crash course? Probabily. Anyway, I try to ask this here. I have a control: customer_controller. From here, I can do something like: @id = 1 @customer = Customer.find(id) Now @customer will contain all the fetched record for customer with id = 1. Great. From this controller I will render an html page. Somewhere the view will print test. SOmething like: "This is your account" But I want to fetch this text from the database. The customer table also have a field named lang. Having a table called "page_texts" I want from customer_controller, using the field "lang* for the current customer, fetch all the record for the customer''s language. Should I do this from customer_controller? Or is it a bad idea? Do I need to create the lang_controller? And how do I, from customer_controller, include the rows from the language table? Thanks. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 9 June 2011 08:06, Sta Canovist <stacanovist-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi there > Yes, I know very little of ruby. I must take a crash course?Work through the rails tutorial at railstutorial.org which is free to use online. Even though it may appear that this app is not similar to what you want to write you will learn a great deal.> Probabily. > Anyway, I try to ask this here. > > I have a control: customer_controller. > From here, I can do something like: > > @id = 1 > @customer = Customer.find(id) > > Now @customer will contain all the fetched record for customer with id > = 1. Great. > > From this controller I will render an html page. Somewhere the view > will print test. SOmething like: > > "This is your account" > > But I want to fetch this text from the database. > The customer table also have a field named lang. > Having a table called "page_texts" I want from customer_controller, > using the field "lang* for the current customer, fetch all the record > for the customer''s language. > > Should I do this from customer_controller? Or is it a bad idea? > Do I need to create the lang_controller? > And how do I, from customer_controller, include the rows from the > language table?Have a look at the Rails Guide on ActiveRecord relationships ( and the other guides for that matter). Once you have setup the relationships properly then you will be able to do things like @user.page_texts to give you all the texts for that user You will probably want a languages table and then something like User belongs to Language and User has many page_texts through language. When you have worked through railstutorial.org and made sure you understand the ActiveRecord relationships guide then ask again if you are not sure how to proceed. As a final note, though, if you are doing internationalisation then there may be better ways to achieve this. Still do the tutorial and look at the guides first though. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Jun 9, 9:42 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Work through the rails tutorial at railstutorial.org which is free to > use online. Even though it may appear that this app is not similar to > what you want to write you will learn a great deal.Thanks I will. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
There are some good books about beginning Rails development - even some of those geared toward Rails 2 will give you a basic understanding of the model view controller theory which is Rails. Don''t be afraid to try things as well, you''ll learn a lot more this way. On Jun 9, 3:06 am, Sta Canovist <stacanov...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi there > Yes, I know very little of ruby. I must take a crash course? > Probabily. > Anyway, I try to ask this here. > > I have a control: customer_controller. > From here, I can do something like: > > @id = 1 > @customer = Customer.find(id) > > Now @customer will contain all the fetched record for customer with id > = 1. Great. > > From this controller I will render an html page. Somewhere the view > will print test. SOmething like: > > "This is your account" > > But I want to fetch this text from the database. > The customer table also have a field named lang. > Having a table called "page_texts" I want from customer_controller, > using the field "lang* for the current customer, fetch all the record > for the customer''s language. > > Should I do this from customer_controller? Or is it a bad idea? > Do I need to create the lang_controller? > And how do I, from customer_controller, include the rows from the > language table? > Thanks.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.