Re: [Rails] Re: Beginner Question
Please quote the previous message when replying. This is a mailling list not a forum, though you may be accessing it via a forum like interface, so it is important to quote so we know what you are replying to. See further comments below. On 8 March 2016 at 01:03, Hitesh Sancheti wrote: > This is what I see when I click on Show Posts link > > 2016-03-08T01:02:38.242828+00:00 heroku[router]: at=info method=GET > path="/posts" host=damp-dusk-43146.herokuapp.com > request_id=b362a590-741a-4b32-8ba6-ad2c8d916413 fwd="67.244.90.19" > dyno=web.1 connect=0ms service=21ms status=200 bytes=2749 > 2016-03-08T01:02:38.227479+00:00 app[web.1]: Started GET "/posts" for > 67.244.90.19 at 2016-03-08 01:02:38 + > 2016-03-08T01:02:38.232514+00:00 app[web.1]: Processing by > PostsController#index as HTML > 2016-03-08T01:02:38.236506+00:00 app[web.1]: Rendered > posts/index.html.erb within layouts/application (2.1ms) That tells us that the server is running GET /posts and is rendering PostsController#index. That does not sound like the Home Page that you said it was rendering. Which controller action did you want it to run? Unfortunately you have not provided the other information I asked for, which was to show us a few lines round the Show Posts link in your code. Please provide that, unless posts#index is the action you want it to run. Also have a look at the html that the code is generating (View Page source in the browser, or something similar depending on which browser you are using). Copy/paste the relevant section here. But again, please look at it and see if it helps you to work out what the problem is. Again if posts#index is the action you want it to run then no need as that bit is working. > 2016-03-08T01:02:38.240308+00:00 app[web.1]: Rendered > posts/_navigation.html.erb (1.1ms) > 2016-03-08T01:02:38.240592+00:00 app[web.1]: Completed 200 OK in 8ms > (Views: 7.1ms | ActiveRecord: 0.0ms) That bit looks a bit odd as it only seems to have rendered what I assume is your nav bar. Perhaps this is the issue. If posts#index is the action you expected to be called but it is not rendering the view you expect then have a look at that code and see if you can see the issue. Otherwise paste the index action code here. But don't just post lots of stuff. Try and understand it first and any bits you don't understand then ask us for help. 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%3D0gLted659ZPxXcSPaTCJCUi5t1no9PAU%2B%3DG16qvNOBEKW4g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: Beginner Question
This is what I see when I click on Show Posts link 2016-03-08T01:02:38.242828+00:00 heroku[router]: at=info method=GET path="/posts" host=damp-dusk-43146.herokuapp.com request_id=b362a590-741a-4b32-8ba6-ad2c8d916413 fwd="67.244.90.19" dyno=web.1 connect=0ms service=21ms status=200 bytes=2749 2016-03-08T01:02:38.227479+00:00 app[web.1]: Started GET "/posts" for 67.244.90.19 at 2016-03-08 01:02:38 + 2016-03-08T01:02:38.232514+00:00 app[web.1]: Processing by PostsController#index as HTML 2016-03-08T01:02:38.236506+00:00 app[web.1]: Rendered posts/index.html.erb within layouts/application (2.1ms) 2016-03-08T01:02:38.240308+00:00 app[web.1]: Rendered posts/_navigation.html.erb (1.1ms) 2016-03-08T01:02:38.240592+00:00 app[web.1]: Completed 200 OK in 8ms (Views: 7.1ms | ActiveRecord: 0.0ms) -- 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/5b0470990069f03563e1c2a08f512173%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] Re: Beginner Question
On 7 March 2016 at 15:40, Hitesh Sancheti wrote: > http://damp-dusk-43146.herokuapp.com/ > From the top nav bar, the 'Show Post' link takes me back to the home > page. But I want it to take me to > https://github.com/hitesh99/ror_blog/blob/master/app/views/posts/allposts.html.erb > > Is there anything that needs to be defined in routes? > https://github.com/hitesh99/ror_blog/blob/master/config/routes.rb What do you see in the log file when you click the link? Having studied that if you do not understand it then copy/paste a few lines of code around the Show Post link so we can see what you are doing, and also post the relevant section of the log. If you had something missing from the routes you would get a routing error. 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%3D0gLvithz11CVhBk0t11xVdsJR_9PXp%3DZ7pqNGCM3pDTGLGg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: Beginner Question
http://damp-dusk-43146.herokuapp.com/ >From the top nav bar, the 'Show Post' link takes me back to the home page. But I want it to take me to https://github.com/hitesh99/ror_blog/blob/master/app/views/posts/allposts.html.erb Is there anything that needs to be defined in routes? https://github.com/hitesh99/ror_blog/blob/master/config/routes.rb -- 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/1d9e9c7cee4ae5486ffd6e79e53e80f2%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: Beginner Question
Would that not normally be just posts_path On Monday, 7 March 2016 07:00:16 UTC+8, Ruby-Forum.com User wrote: > > Hello everyone, I just started off with RoR and had a question. > > I wanted to link my 'Show All Posts' to my allposts.html.erb which will > display all the posts that are created but I am having difficulty in > doing so. Do I need to define this in routes.rb file. I just want to > display all posts when that link is clicked. > > > <%= link_to "New Post", new_post_path %> > <%= link_to "Show All Posts", '#' %> > Contact > > > allposts.html.erb contents > <% @posts.each do |post| %> > <%= post.title %> > <%= post.body%> > <%= link_to "Show Posts", post %> > <% end %> > > -- > 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/45d72f5a-e186-43f7-b962-b201f2602dd5%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: beginner in Ruby on rails
Hi! >i am beginner in ruby on rails I'm also a beginner.. I have found these tutorials and books very useful: http://guides.rubyonrails.org/getting_started.html, http://associacio-aoe.org/aoe/files/documentacio/volcanica/2007/introduccion_ruby_on_rails.pdf (spanish), http://ptgmedia.pearsoncmg.com/images/9780321832054/samplepages/0321832051.pdf Currently, I work in RGSoC. If you want to learn together or have any problem, search me as @claucece on twitter. I have some Rails mentors, so I can help :) -- 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/edb95a15-b8c4-49e0-9300-5a0d37d2b149%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: beginner in Ruby on rails
Thank you, @Colin. Good to know that I have not taken a wrong direction for the very beginning. :) -- 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/a0f2f2941597a21e2e17c6a372e15b7d%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
Re: [Rails] Re: beginner in Ruby on rails
On 20 July 2015 at 20:34, Taras Matsyk wrote: > ... > @Colin, can I have question. Why should I use rvm? > I am using rbenv at the moment, which reminds me a python virtualenv and > I am pretty satisfied with it. > > So what is the advantage? Yes I believe you are right, rbenv is also ok. 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%3D0gLvMJdv8woc83LmoqnvPntxFrN1QgQw-UP07CRsZao5%3Drw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: beginner in Ruby on rails
Hey, beginner, send me a message. We are in the same boat =D @Colin, can I have question. Why should I use rvm? I am using rbenv at the moment, which reminds me a python virtualenv and I am pretty satisfied with it. So what is the advantage? -- 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/d4a87248637c308d14ae4be24b6c6cb7%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: (Beginner) ActionController::UrlGenerationError - No route matches
Colin Law wrote in post #1146273: > It is because you have told it that > the controller is articles/new, whereas in fact this is the complete > path. You just need > > <%= link_to 'Add new weird stuff', new_article_path %> :-O Now after you explained it, it became obvious!! Thanks a lot. Ronald -- 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/19973abde8d9a9b492469c0295ec4637%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: (Beginner) ActionController::UrlGenerationError - No route matches
try something like this: <%= link_to t('.new', :default => t("helpers.links.new")), new_article_path(article), :class => 'btn btn-mini' %> Where class =>'btn btn-mini' is un type of button when you use bootstrap theme if you don't use it try whitout this option. -- 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/1133c79662a59c7782c20832480b15f5%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: beginner to ruby programming
Jaya Ruhil wrote in post #1141029: > hi every one , > i am beginner to ruby, i don't know a little bit of ruby, but i have to > learn it bcz i m going to work as a system admin , and for client server > automation using puppet i required concept of ruby, can any body help in > in directing me , towards learning it quickly and easily. http://tryruby.org/ -- 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/2965214fba473d6c1d97bd0d1d2c641f%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: beginner to ruby programming
Jaya Ruhil wrote in post #1141029: > hi every one , > i am beginner to ruby, i don't know a little bit of ruby, but i have to > learn it bcz i m going to work as a system admin , and for client server > automation using puppet i required concept of ruby, can any body help in > in directing me , towards learning it quickly and easily. I would also like to be able to learn Ruby quickly and easily. Preferably before lunch. I would also like to know how to do my taxes. If anyone can teach me real quick how to do taxes. Preferably before lunch. -- 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/5a8769b93e1ec4dde34c6e7023b73f20%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.
[Rails] Re: Beginner
On Wednesday, August 29, 2012 6:34:57 PM UTC+1, Bala Ramachandran wrote: > > I am someone with no programming experience. > > 1. What is the best way for me to learn Ruby on Rails > Personally I believe at least some knowledge of ruby is useful. People speak well of rubykoans.com > 2. How long will it take? > That's entirely dependant on how fast you pick things up. If you've really got no programming experience at all then I would have thought it would be at least a multi month process. 3. What is the back end database that Ruby uses. > 2 of the more common ones are Postgres & Mysql, but people also use oracle, sql server, sqlite3 and also non relational stores such as mongodb, couchdb, riak etc. Fred 4. Are there any components that need to be bought out? > > 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/bwAn6Jo2QfwJ. For more options, visit https://groups.google.com/groups/opt_out.
[Rails] Re: Beginner here: What does it take to find a decent job as Rails developer and live from it
thanks, ruby! On 7 jan, 06:55, ruby wrote: > github.com > find people on quora.com and stackoverflow. > > twitter isn't a bad place to start streaming tags. > and i think it's always good to form relationships first > then ask for a recommendation 2nd. people still hire people. > > i have a freelance opt if you're ever interested. > > On Jan 5, 2012, at 2:40 AM, Francisco Lucas wrote: > > > > > > > > > Fabricia, where can I find this opportunities here in Brazil? > > > On 4 jan, 17:43, FaBritze wrote: > >> Hello there! > > >> Rails is growing up very fast in the market > > >> To give you an idea, here in Brazil there are many opportunities for > >> RoR web development, both in small and in multinational companies and > >> some academic attempts too > > >> About "employable" Rails developer... > > >> This is very concerning... > > >> Depend's the region or companie... > > >> Experience is more needed than studies/certificates, but without these > >> you will have to make a good advertising and have a presentable > >> portfolio to convince companies that you really have a difference in > >> your work > > >> The combination would be ideal > > > -- > > 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@googlegroups.com. > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner here: What does it take to find a decent job as Rails developer and live from it
Fabricia, where can I find this opportunities here in Brazil? On 4 jan, 17:43, FaBritze wrote: > Hello there! > > Rails is growing up very fast in the market > > To give you an idea, here in Brazil there are many opportunities for > RoR web development, both in small and in multinational companies and > some academic attempts too > > About "employable" Rails developer... > > This is very concerning... > > Depend's the region or companie... > > Experience is more needed than studies/certificates, but without these > you will have to make a good advertising and have a presentable > portfolio to convince companies that you really have a difference in > your work > > The combination would be ideal -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Beginner here: What does it take to find a decent job as Rails developer and live from it
Experience is good, especially comercial experience of Rails. If you've been doing Rails for 5 years but you are actually employed as a Java programmer you will probably lose to someone who has been employed as a Rails developer for 2 years. It's hard to sell enthusiasm over experience :( -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner here: What does it take to find a decent job as Rails developer and live from it
Hello there! Rails is growing up very fast in the market To give you an idea, here in Brazil there are many opportunities for RoR web development, both in small and in multinational companies and some academic attempts too About "employable" Rails developer... This is very concerning... Depend's the region or companie... Experience is more needed than studies/certificates, but without these you will have to make a good advertising and have a presentable portfolio to convince companies that you really have a difference in your work The combination would be ideal -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: [Beginner] fields_for within each loop
Thank you Fred for another reply. But having relationship report->question->answer will lead to unnecessary generation of the question per each report. In my case, question is same for all reports. Could you please guide me what I should do then? I feel like I'm stuck in db model now. Your advise will be very much appreciated. -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: [Beginner] fields_for within each loop
It doesn't work as I expected. I changed the controller and view but it doesn't work in report_controller.rb def new ... QuestionSingle.each do |qs| report.answer_singles.build ... end so answer_single generated as many as questions. So when I call answer_singles in the fields for it calls every answer_singles generated. <% QuestionSingle.all.each_with_index do |question, index| %> <%= index+1 %>. <%= question.content %> <%= f.fields_for :answer_singles do |answer| %> <%= answer.text_area :content %> <%= answer.hidden_field :question_single_id, {:value => index} %> <% end %> <% end %> I have designed models not like report -> question -> answer report -> answer (due to the predefined questions by scaffolding) For all report same questions will be fed and answers have report_id, question_id. My question is how I can use answer same as the question_id. Simple fields for shows all answer fields having same report_id. Let me know if there's better design for predefined questions. Thanks, June -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: [Beginner] fields_for within each loop
Thank you very much Frederick. I have changed my code according to it. But in the form how I can implement this? Once I'm using the same code it will display 3 fields since it's using fields_for loop for all answers. What can I use in this case? -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: [Beginner] fields_for within each loop
I found from the development log that I'm passing question_single_id as nil. Seems to be my code of this part is not working <%= f.fields_for :answer_singles, {:question_single_id => index} do |answer| %> <%= answer.text_area :content, {:question_single_id => index} %> What I meat to do was to assign question_single_id when I fill the answer :content. And look up a text_area per each question. Is there any good solution for text_area and fields_for usage? I know I'm way far from CRUD development but what to do. (codes are getting uglier) What i should implement is like a quiz system with given questions. User login -> answer the given questions -> end Admin -> edit questions or review user answers -> end -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: [Beginner] fields_for within each loop
Sure, Thank you very much. reports_controller.rb def new @report = Report.new @report.answer_singles.build respond_to do |format| format.html # new.html.erb format.json { render :json => @report } end end _form.html.erb <%= form_for(@report) do |f| %> <% if @report.errors.any? %> <%= pluralize(@report.errors.count, "error") %> prohibited this report from being saved: <% @report.errors.full_messages.each do |msg| %> <%= msg %> <% end %> <% end %> <%= f.label :project_id, "Project Runner" %> <%= f.select :project_id, Project.all.collect {|d| [Project::P_PARTNER[d.partner], d.partner]} %> <%= f.label :finalized %> <%= f.select :finalized, [["Yes", true], ["No", false]] %> <%= f.label :emails %> <%= f.number_field :emails %> <% QuestionSingle.all.each_with_index do |question, index| %> <%= index+1 %>. <%= question.content %> <%= f.fields_for :answer_singles, {:question_single_id => :index} do |answer| %> <%= answer.text_area :content, {:question_single_id => :index} %> <% end %> <% end %> <%= f.submit %> <% end %> Others are just as the scaffold output (index, edit, new, show) -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: [Beginner] fields_for within each loop
By making it nested_attributes I'm able to control it but still some weird loop. I don't fully understand how loop works in rails so please advise. First this code makes one text area per each question. <% QuestionSingle.all.each_with_index do |question, index| %> <%= index+1 %>. <%= question.content %> <%= f.fields_for :answer_singles, {:question_id => :index} do |answer| %> <%= answer.text_area :content %> <% end %> <% end %> After I put answers and edit it makes number of answer text area same as questions. Please let me know how I can make the text area per question. Thank you and regards, June -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Beginner issue - databases reference
On 22 September 2011 02:21, Justin D. wrote: Please don't top post, it makes it difficult to follow the thread. Insert your reply at appropriate points in the previous post. Thanks. > Well... I've read some tutorials and basically, what I had to do was to > create a database with the command scaffold. I had to choose :references > as the type of one of my table entry... But the thing is I can't figure > which entry to reference to... I think the confusion here is that you have said that you have two databases. I suspect that you mean two tables in one database. Is that correct? I suggest that you have a look at the Rails Guides, starting with Getting Started, then ActiveRecord Associations, Routing, and Debugging. I mean a good work through, do not just skim over then. Then (or in parallel) work through some tutorials. railstutorial.org is good and free to use online. Make sure that you have Rails 3 installed and any tutorial you use is for that version of rails. Colin -- gplus.to/clanlaw -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Beginner issue - databases reference
On Wed, Sep 21, 2011 at 6:21 PM, Justin D. wrote: > Well... I've read some tutorials and basically, what I had to do was to > create a database with the command scaffold. Sorry, that doesn't make any sense to me. You might want to step back and document exactly what you're done so far, and post that and the code for the models you've (I'm guessing) created via scaffolding. It would help to know what version of Rails you're using, as well. -- Hassan Schroeder hassan.schroe...@gmail.com http://about.me/hassanschroeder twitter: @hassan -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner issue - databases reference
Well... I've read some tutorials and basically, what I had to do was to create a database with the command scaffold. I had to choose :references as the type of one of my table entry... But the thing is I can't figure which entry to reference to... -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: beginner
You can also try out Rails tutorial http://ruby.railstutorial.org/ruby-on-rails-tutorial-book It's pretty good and the author got Ruby Heroes Award at this year's RailsConf for his contribution to community There's another great beginner free course by codeschool, which you can try out - http://www.codeschool.com/courses/rails-for-zombies Once you are get a hang of how things work in Rails, then guides.rubyonrails.org and api.rubyonrails.org would be good reference points And you can start watching Railscasts once you have learnt enough to read and understand someone else's code. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/-bq9Wf7OKHwJ. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: (Beginner) Finding a database object within a time interval
Thanks for the tip, got a bit cleaner. On May 8, 8:02 pm, Frederick Cheung wrote: > On 8 May 2011, at 18:51, Anders_P wrote: > > > Thanks for your answer, I think I got it to work. > > > def current_tee > > current_time = Time.now > > @current_tee = Tee.find :all, :conditions => [ > > "featured = true AND start_date < '#{current_time}' AND end_date > >> = '#{current_time}'" > > ] > > end > > > I had also forgot ' ' before and after '#{current_time}'. > > If you use the placeholder syntax ( ie :conditions => ["start_date < ?", > current_time]) then you don't need to worry about that and other SQL > escaping problems > > Fred > > > > > Thanks! > > > // Anders > > > On May 8, 5:13 pm, Frederick Cheung > > wrote: > >> On 8 May 2011, at 13:58, Anders_P wrote: > > >>> Hello, > > >>> I'm trying to create a find statement that should find an element > >>> which start_date and end_date are within Time.now. If I for example > >>> have an object with a start_date of 2011-05-04 and end_date of > >>> 2011-05-19, the find statement should find the elment(s) that are > >>> within that time peroid. My code looks like this: > > >>> def current_tee > >>> @current_time = Time.now > >>> @current_tee = Tee.find(:conditions => [ > >>> "id = ? AND featured => true AND start_date > #{@current_time} > >>> AND end_date <= #{@current_time}", params[:id] > >>> ]) > >>> end > > >> You either need Tee.find :all, :conditions => ... > > >> Or Tee.find some_id (or Tee.find :first, :conditions => ... if you only > >> want one record) > > >> But you've got something halfway between the two > > >> Fred > > >>> And: > > >>> def show > >>> @tee = current_tee > >>> respond_to do |format| > >>> format.html # show.html.erb > >>> format.xml { render :xml => @tee } > >>> end > >>> end > > >>> I keep getting this error: Couldn't find Tee without an ID. > > >>> Any tips on how to solve this? > > >>> Thanks! > >>> // Anders > > >>> -- > >>> 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@googlegroups.com. > >>> To unsubscribe from this group, send email to > >>> rubyonrails-talk+unsubscr...@googlegroups.com. > >>> For more options, visit this group > >>> athttp://groups.google.com/group/rubyonrails-talk?hl=en. > > > -- > > 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@googlegroups.com. > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: (Beginner) Finding a database object within a time interval
On 8 May 2011, at 18:51, Anders_P wrote: > Thanks for your answer, I think I got it to work. > > def current_tee > current_time = Time.now > @current_tee = Tee.find :all, :conditions => [ >"featured = true AND start_date < '#{current_time}' AND end_date >> = '#{current_time}'" > ] > end > > I had also forgot ' ' before and after '#{current_time}'. > If you use the placeholder syntax ( ie :conditions => ["start_date < ?", current_time]) then you don't need to worry about that and other SQL escaping problems Fred > Thanks! > > // Anders > > > > On May 8, 5:13 pm, Frederick Cheung > wrote: >> On 8 May 2011, at 13:58, Anders_P wrote: >> >>> Hello, >> >>> I'm trying to create a find statement that should find an element >>> which start_date and end_date are within Time.now. If I for example >>> have an object with a start_date of 2011-05-04 and end_date of >>> 2011-05-19, the find statement should find the elment(s) that are >>> within that time peroid. My code looks like this: >> >>> def current_tee >>> @current_time = Time.now >>> @current_tee = Tee.find(:conditions => [ >>>"id = ? AND featured => true AND start_date > #{@current_time} >>> AND end_date <= #{@current_time}", params[:id] >>> ]) >>> end >> >> You either need Tee.find :all, :conditions => ... >> >> Or Tee.find some_id (or Tee.find :first, :conditions => ... if you only want >> one record) >> >> But you've got something halfway between the two >> >> Fred >> >> >> >> >> >>> And: >> >>> def show >>>@tee = current_tee >>>respond_to do |format| >>> format.html # show.html.erb >>> format.xml { render :xml => @tee } >>>end >>> end >> >>> I keep getting this error: Couldn't find Tee without an ID. >> >>> Any tips on how to solve this? >> >>> Thanks! >>> // Anders >> >>> -- >>> 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@googlegroups.com. >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscr...@googlegroups.com. >>> For more options, visit this group >>> athttp://groups.google.com/group/rubyonrails-talk?hl=en. > > -- > 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@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: (Beginner) Finding a database object within a time interval
Thanks for your answer, I think I got it to work. def current_tee current_time = Time.now @current_tee = Tee.find :all, :conditions => [ "featured = true AND start_date < '#{current_time}' AND end_date >= '#{current_time}'" ] end I had also forgot ' ' before and after '#{current_time}'. Thanks! // Anders On May 8, 5:13 pm, Frederick Cheung wrote: > On 8 May 2011, at 13:58, Anders_P wrote: > > > Hello, > > > I'm trying to create a find statement that should find an element > > which start_date and end_date are within Time.now. If I for example > > have an object with a start_date of 2011-05-04 and end_date of > > 2011-05-19, the find statement should find the elment(s) that are > > within that time peroid. My code looks like this: > > > def current_tee > > @current_time = Time.now > > @current_tee = Tee.find(:conditions => [ > > "id = ? AND featured => true AND start_date > #{@current_time} > > AND end_date <= #{@current_time}", params[:id] > > ]) > > end > > You either need Tee.find :all, :conditions => ... > > Or Tee.find some_id (or Tee.find :first, :conditions => ... if you only want > one record) > > But you've got something halfway between the two > > Fred > > > > > > > And: > > > def show > > @tee = current_tee > > respond_to do |format| > > format.html # show.html.erb > > format.xml { render :xml => @tee } > > end > > end > > > I keep getting this error: Couldn't find Tee without an ID. > > > Any tips on how to solve this? > > > Thanks! > > // Anders > > > -- > > 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@googlegroups.com. > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: (Beginner) Learning Rspec (help!)
Ouch embarrassing. :D Thanks! On 23 Apr, 22:15, Frederick Cheung wrote: > On Apr 23, 8:58 pm, Anders_P wrote: > > > > > > > Hello! > > > And: > > > class NewsletterReceiversController < ApplicationController > > def create > > @newsletter_receiver = > > NewsletterReceiver.new(params[:newsletter_receiver]) > > if @newsletter_receiver.save > > flash[:notice] = "A message" > > redirect_to root_path > > else > > render 'pages/home' > > end > > end > > end > > > My NewsletterReceiversController specs looks like this: > > > require 'spec_helper' > > > describe NewsletterReceiversController do > > > describe "Success" do > > > before(:each) do > > @attr = { :email => "exam...@example.com" } > > end > > > it "should create a receiver" do > > lambda do > > post :create, :newsletter_reveiver => @attr > > end.should change(NewsletterReceiver, :count).by(1) > > end > > Step through your code and you'll see that you've got a typo here. > > Fred > > > > > end > > end > > end > > > This gives me the following error: > > > Failure/Error: lambda do > > count should have been changed by 1, but was changed by 0 > > > Anyone got any tips on how to solve this? > > > Thanks > > // Anders -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: (Beginner) Learning Rspec (help!)
On Apr 23, 8:58 pm, Anders_P wrote: > Hello! > > > > And: > > class NewsletterReceiversController < ApplicationController > def create > @newsletter_receiver = > NewsletterReceiver.new(params[:newsletter_receiver]) > if @newsletter_receiver.save > flash[:notice] = "A message" > redirect_to root_path > else > render 'pages/home' > end > end > end > > My NewsletterReceiversController specs looks like this: > > require 'spec_helper' > > describe NewsletterReceiversController do > > describe "Success" do > > before(:each) do > @attr = { :email => "exam...@example.com" } > end > > it "should create a receiver" do > lambda do > post :create, :newsletter_reveiver => @attr > end.should change(NewsletterReceiver, :count).by(1) > end Step through your code and you'll see that you've got a typo here. Fred > end > end > end > > This gives me the following error: > > Failure/Error: lambda do > count should have been changed by 1, but was changed by 0 > > Anyone got any tips on how to solve this? > > Thanks > // Anders -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner Help - Iterating and Displaying From Models with Relationship
Thank you very much everyone! Fred, your advise was spot on. Worked like a charm! <% Company.find(1).applications.each do |app| %> <%= app.name %> <% end %> Perfecto! Clint, thanks for the tip on the inspect function, I missed that. It probably would have been the best way to debug and trial/error the solution. Once again thank you all for the help :) On Feb 22, 1:44 pm, Michael Pavling wrote: > On 22 February 2011 16:52, Bryan Crossland wrote: > > > Hi Ryan, > > Hiya, > Can you not top-post, please. It makes it hard to know what you're > exactly replying to. TIA. > > >There are two ways to get it to display what you want. Remove the > > = and change your block to read { |app| puts app.name } or do as > > That's not gonna do much good, as "puts" is going to output on the > server console. The one way to do it is as Fred said. > > Michael -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Beginner Help - Iterating and Displaying From Models with Relationship
On 22 February 2011 16:52, Bryan Crossland wrote: > Hi Ryan, Hiya, Can you not top-post, please. It makes it hard to know what you're exactly replying to. TIA. >There are two ways to get it to display what you want. Remove the > = and change your block to read { |app| puts app.name } or do as That's not gonna do much good, as "puts" is going to output on the server console. The one way to do it is as Fred said. Michael -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Beginner Help - Iterating and Displaying From Models with Relationship
Hi Ryan, Your loop is correct. The issue how erb is interpreting what you are asking it to do. The = is telling erb to spit out the contest of the array Company.find(1).applications.each without running the block it has. There are two ways to get it to display what you want. Remove the = and change your block to read { |app| puts app.name } or do as Fredrick suggested and write you code like so: <% Company.find(1).applications.each do |app| %> <%= app.name %> <% end %> Thanks, B. On Tue, Feb 22, 2011 at 2:31 AM, Clint wrote: > I am not at my computer, so I can't help out with code. > Basically you need to dig one layer deeper. The above is an > array of Applications. Try to <%=raise Company.find(1).inspect %> to > display > the returned value/array. From there you can play around till it > satisfy your needs. > > On Feb 22, 4:40 am, Ryan wrote: >> This should probably be easy but for some reason I can't get past a >> simple routine. I have a model for Companies and for Applications. A >> company has many applications. So in this instance I have a company >> id and I want to find all applications associated with that company. >> I tried the following: >> >> <%= Company.find(1).applications.each { |app| app.name } %> in my >> view. >> >> This returns "##> 0xb672f1d0>##> 0xb672ef50>##> 0xb672e924>#" when the view is rendered. >> >> I'm not really sure what this is, but it does have one entry for each >> of my applications for that company. So I know it is creating the >> right number of entries just not sure what the output means. >> >> I'm sure I am doing something monumentally stupid but I can't seem to >> find any examples of this that return this output. Any help that can >> be provided is very much appreciated. >> >> Thank you! > > -- > 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@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner Help - Iterating and Displaying From Models with Relationship
I am not at my computer, so I can't help out with code. Basically you need to dig one layer deeper. The above is an array of Applications. Try to <%=raise Company.find(1).inspect %> to display the returned value/array. From there you can play around till it satisfy your needs. On Feb 22, 4:40 am, Ryan wrote: > This should probably be easy but for some reason I can't get past a > simple routine. I have a model for Companies and for Applications. A > company has many applications. So in this instance I have a company > id and I want to find all applications associated with that company. > I tried the following: > > <%= Company.find(1).applications.each { |app| app.name } %> in my > view. > > This returns "## 0xb672f1d0>## 0xb672ef50>## 0xb672e924>#" when the view is rendered. > > I'm not really sure what this is, but it does have one entry for each > of my applications for that company. So I know it is creating the > right number of entries just not sure what the output means. > > I'm sure I am doing something monumentally stupid but I can't seem to > find any examples of this that return this output. Any help that can > be provided is very much appreciated. > > Thank you! -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: beginner question: database relationships
Ok, so I've discovered that user.topics.build can be done in the User edit form (in my project, not in the gem). However, I'm not sure how to save this newly built topic; normally this would be done by the topic controller catching the POST right? But in this case it's not the topic controller that gets the POST. -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: beginner question: database relationships
Thanks for the advice, follow up questions: I'm using Devise for authentication. I think this means the controller inside the Devise gem handles user model editing. So, how does one add Topics as a nested resource for Users? I understand this normally requires three things: a) nested partial form for creating topics owned by users added into the users edit form, b) @user.build_topic added into the Users controller edit action, c) accepts_nested_attributes_for :topics added into User model. So basically two questions: -is it standard practice to have to modify the gem like this (in the Devise controller)? is there a less intrusive way? -Are the steps that I required necessary & sufficient? -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: beginner question: database relationships
Alexander Farley wrote in post #978480: > That helps a lot. To clarify, I am not necessarily looking to create > seed data upon creation of a User; just trying to figure out how to > "link" the creation of the two resources. The create_model method sounds > about right. > > Anyway, your info gives me plenty to read up on for now. Thanks again > > Alex Hi Alex, To simplify how you see those methods, you don't necessarily have to create a new user object. You can use: user = User.first .. and then look through the methods for the user object. The reason why I supplied two different puts statements is so that you can see the difference between methods for each. One is showing the methods available to the User "class", while the other is showing methods available to the User "object". Look for build_ methods as well as these will not save the record until you forcibly save the record. It will allow you a little more flexibility with your getting used to the console. Also notice that the create_ and build_ methods available to the user object are usuable with has_one relationships. While the same methods are usuable with objects from models that have belongs_to relationships. So, as an example: has_many :moderators has_many :topics has_many :posts has_one :userprofile You would see the create_ and build_ methods for a user object only for userprofile. user = User.first user.methods.sort.each do |method| p method end ... methods.. ... build_userprofile ... create_userprofile ... etc.. Likewise, for topic, if you had: class Topic < ActiveRecord::Base belongs_to :user #... end topic = Topic.first topic.methods.sort.each do |method| p method end ... methods.. ... build_user ... create_user ... etc.. Test out a brief example just to see what happens: topic.build_user As for accessing the table data for each model with has_one or has_many from the user model.. topics = User.first.topics And if you want to iterate over the returned array.. topics.each do |topic| p topic end -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: beginner question: database relationships
That helps a lot. To clarify, I am not necessarily looking to create seed data upon creation of a User; just trying to figure out how to "link" the creation of the two resources. The create_model method sounds about right. Anyway, your info gives me plenty to read up on for now. Thanks again Alex -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: beginner question: database relationships
Alexander Farley wrote in post #978434: > So, here's my goal: I want an "intuitive" flow of "create user"->"create > user's topics" -> "add blacklist for topic". Right now, my "edit user" > view doesn't allow adding topics (topics must be added manually, with a > known user_id). So, you want to create a new user and automatically create a topic for that user? Why? Are you just trying to add some seed data for the user? If so, you can do: user = User.new(:email => 'b...@example.com', :hashed_password => '...') user.create_topic(... your topic fields ...) .. that's assuming you have the fields I expressed above. When a model belongs to another, you automatically get the create_model method.. But, if you aren't trying to automatically populate some seed data, why are you trying to create a topic for a user? > Am I going in the right direction? Is there a normal/default way of > editing (adding) a table entry's "children"? You should check out the methods for the model. Try the following in your rails console: User.methods.sort.each do |list| p list end user = User.new user.methods.sort.each do |list| p list end The console is your best friend right now. I would check out the guides on active record so you can gain a better understanding of how to work with database records: http://guides.rubyonrails.org/ Look over active record associations and active record callbacks. You can handle the blacklist/raw/etc. that you are trying to work with using before_create and after_create in the topic model. That way when a topic is being created .. something is done.. and after it's created something else is done.. With not too much to go on, this is all I can offer at the moment. -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner "rails new" question
Sorry for not being explicit: > > Mac OS 10.6 (snow leopard) rails -v = 2.3.5 I think I had installed Rails 3, but it bumped me back to 2.3.5. At least I was going through the book's steps successfully. I got RVM working in terminal now. I hadn't done "source .bash_profile" to load it in. That did the trick. RVM commands now work in the terminal. I wasn't sure if .bash_profile needed extra code in there, but it looks like it can just be a plain, naked text file with the one piece of RVM code in there. Good to know. I installed Rails 3 (again perhaps) and now rails -v is 3.0.5. I did my "rails new demo_app" and I got all the appropriate files this time. Thanks for the responsive help! I'm back on track now (or back on the Rails, as it were) case closed :) Ian -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner "rails new" question
Please quote when replying. Dahlby wrote in post #977793: > Thanks for all the replies. > It looks like things changed after shutting down and starting back up > the > next day. My rails went back to version 2.3.5 for some reason. That > would > explain the different folder set I get when doing a "new" command. The > Hartl > book recommended having both Rails 2 and 3, in case I needed to switch > back > and forth. That is a great idea, but then you need to either use RVM or explicitly specify the version. > > I installed RVM but am having a frustrating time trying to get the > Terminal > to recognize the command. What OS are you using? > I'm going backwards it seems :( > > If I had a .bash_profile, I don't now. I created one, put it in my home > directory, and added the suggested RVM code to it: > > [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This > loads RVM into a shell session. > > ...but Terminal still doesn't acknowledge rvm as a command. How do you know? What happens when you try to use it? > I don't have a .bashrc or .profile file either. All I found in the home > directory was .bash_history. .bash_profile should be fine. Did you start a new shell or use "source" to reload your profile after editing it? > Not sure how I got it to work on Monday. > > My gem list rails is: > rails (2.3.5, 1.2.6) So you don't have Rails 3 at all, then, at least not accessible with your current settings. Since you neglected to quote when replying, you forgot to answer my entire post. I asked about the output of rails -v. > > I guess my initial question is answered and now am needing basic help > with > rvm. I went through the RVM site's troubleshooting section, but it's > still a > little technical for me. > Development is technical. That's life. What don't you understand? > Thanks for any further help!! > > Ian Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org Sent from my iPhone -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner "rails new" question
Thanks for all the replies. It looks like things changed after shutting down and starting back up the next day. My rails went back to version 2.3.5 for some reason. That would explain the different folder set I get when doing a "new" command. The Hartl book recommended having both Rails 2 and 3, in case I needed to switch back and forth. I installed RVM but am having a frustrating time trying to get the Terminal to recognize the command. I'm going backwards it seems :( If I had a .bash_profile, I don't now. I created one, put it in my home directory, and added the suggested RVM code to it: [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session. ...but Terminal still doesn't acknowledge rvm as a command. I don't have a .bashrc or .profile file either. All I found in the home directory was .bash_history. Not sure how I got it to work on Monday. My gem list rails is: rails (2.3.5, 1.2.6) I guess my initial question is answered and now am needing basic help with rvm. I went through the RVM site's troubleshooting section, but it's still a little technical for me. Thanks for any further help!! Ian -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner "rails new" question
Dahlby wrote in post #977579: > Hi, > > I'm currently slogging my way thru the installation-setting up pages > of Ruby On Rails 3 Tutorial. I'm a bit new at terminal stuff, and am > wrapping my head around getting around hidden directories, github, ssh > keys, blah blah. > > Question: > I'm trying to set up a new app with the command "rails new demo_app". > It instead gives me a directory called "new" with the usual > directories, but not all the usual files are there, like Gemfile or > Readme. Then you are trying to use a Rails 3 tutorial with a Rails 2 (or older) installation. Don't do that. Install Rails 3. > I already set up another app before successfully, where it > generated all the requisite files using my project name in the command > line (rails new first_app). I'm wondering if I switched something off > inadvertently between then and now. Perhaps. What's the output from rails -v ? How about gem list rails ? Are you using RVM? > > Thanks for any help. (I'm sure to be back with more dumb questions) > > Ian Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org Sent from my iPhone -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner "rails new" question
Lan, When I try it with "rails new demo_app", it's succeeded in generating all files. Are you meaning you can not generate any files now? Even if you change your working directory ( to other directory ) ? On Jan 26, 1:26 pm, Dahlby wrote: > Hi, > > I'm currently slogging my way thru the installation-setting up pages > of Ruby On Rails 3 Tutorial. I'm a bit new at terminal stuff, and am > wrapping my head around getting around hidden directories, github, ssh > keys, blah blah. > > Question: > I'm trying to set up a new app with the command "rails new demo_app". > It instead gives me a directory called "new" with the usual > directories, but not all the usual files are there, like Gemfile or > Readme. I already set up another app before successfully, where it > generated all the requisite files using my project name in the command > line (rails new first_app). I'm wondering if I switched something off > inadvertently between then and now. > > Thanks for any help. (I'm sure to be back with more dumb questions) > > Ian -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner "rails new" question
I'm not sure about the solution but maybe: Rails 3.0 was the first that used rails new app_name command. Previously it was rails app_name. Is that possible you tried first time with rails 3.0 or newer than second time used with 2.3.x? Maybe used the one click installer and got the older version. Maybe. Try rails -v. On Jan 26, 5:26 am, Dahlby wrote: > Hi, > > I'm currently slogging my way thru the installation-setting up pages > of Ruby On Rails 3 Tutorial. I'm a bit new at terminal stuff, and am > wrapping my head around getting around hidden directories, github, ssh > keys, blah blah. > > Question: > I'm trying to set up a new app with the command "rails new demo_app". > It instead gives me a directory called "new" with the usual > directories, but not all the usual files are there, like Gemfile or > Readme. I already set up another app before successfully, where it > generated all the requisite files using my project name in the command > line (rails new first_app). I'm wondering if I switched something off > inadvertently between then and now. > > Thanks for any help. (I'm sure to be back with more dumb questions) > > Ian -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner in Rails Apps
On Jan 11, 12:42 pm, Tiago Dias wrote: > Thanks, this is good resource, I forget to mention that the specification of > project says the app needs to be written in Rails 2, I know it´s a crap > requirement. > The rails guides are good too. The 2.3.x version of those are at http://guides.rubyonrails.org/v2.3.8/ Fred > On Jan 11, 2011, at 11:52 AM, radhames brito wrote: > > > > >http://railstutorial.org/ > > > -- > > 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-t...@googlegroups.com. > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner on RoR
Since I'm a Rails newcomer (coming from Java/C++), I iterated lots of tutorials already, what Brian posted seems good though I haven't explored it thoroughly. http://guides.rubyonrails.org/getting_started.html was very useful for me Watching http://railscasts.com/ was very useful for me Reading this group is very useful for me (: Talking with guys at #rvm, etc.. Just be sure to pick something recent because it can be quite frustrating to do stuff by the book which applies for the old version and doesn't work with the new one. Drop me a line if you need more newbie help (: Martin On Nov 10, 2:16 am, Brian Troutwine wrote: > Michael Hartl's book[1] has a section that addresses just this topic, > in addition to being a good RoR tutorial itself. > > [1]http://railstutorial.org/book#sec:comments_for_various_readers > > > > > > > > On Tue, Nov 9, 2010 at 6:39 PM, Filippos wrote: > > Hello there dear Ruby on Rails experts. > > > I decided to dive into the world of web development and Ruby on Rails > > is my cutting-edge choice for developing and deploying webapps. > > > Unfortunately i can not find any book to help and guide me through the > > language with examples and projects written in simple words. > > So far what i've found online are websites that praise RoR , which is > > fine by me, and blogs or wikies that address the mid level user who is > > switching from a different language and therefore have a basic > > background of programming (c++, java, ruby, visual basic or any other > > object or non object oriented language) > > > What about those who have no background? > > I bought two books already but they require some knowledge of > > programming and after some point it gets complicated. > > > Any help would be a plain miracle because i really want to learn the > > language! > > > -- > > 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-t...@googlegroups.com. > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner cant get rake to work
Okay that fixed the dependicies for the shell, seems like there is something wrong with the gem though. When i try to use rake from my IDE it searches for the gem and it fails. Well I can work around it. Thank you -- 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 post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner cant get rake to work
Well, it's definitely a path problem with Windows...it can't find the executable "rake". It's been a while since I developed rails on a windows machine but when I did I used "ruby installer"...it worked as advertised. http://rubyinstaller.org/ Whatever ruby setup you're using, see if you can find anything about modifying your path so windows knows where to find rubygems. -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner cant get rake to work
On Oct 15, 12:56 am, "Jon W." wrote: > gem list posts > > *** LOCAL GEMS *** > > ... > rake (0.8.7) > ... > > and try installing and updating using gem but still doesnt work Is a bug in Ruby 1.9.2 and the bundled rake. http://groups.google.com/group/rubyinstaller/browse_thread/thread/9817d0c6c8a48a79/ http://redmine.ruby-lang.org/issues/show/3805 The solution is in the RubyInstaller thread (remove of rake.gemspec or rename to rake-0.8.7.gemspec) -- Luis Lavena -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner cant get rake to work
gem list posts *** LOCAL GEMS *** ... rake (0.8.7) ... and try installing and updating using gem but still doesnt work -- 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 post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner cant get rake to work
When you run "gem list" from the command line, does it list "rake (0.8.7)"? If it does not, run "gem install rake". -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Beginner Facing Problem with rake db:migrate
On May 28, 2010, at 3:33 PM, Krishna Venkata wrote: > Hi Philip, > > Earlier I manual dropped all the tables that didn't fix the problem > Now used rake db:drop db:create db:migrate but still geting rake > aborted message.. > > C:\Murali Rubby\demo\library>rake db:drop db:create db:migrate > > (in C:/Murali Rubby/demo/library) > rake aborted! > Mysql::Error: Specified key was too long; max key length is 767 bytes: > CREATE UN > IQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`) > > > (See full trace by running task with --trace) > > So please provide some other Info to fix that... Heh. Google for your mysql error and you'll find this thread which is *exactly* the same problem... even down to the same tables... http://www.ruby-forum.com/topic/157223 Good luck! -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner Facing Problem with rake db:migrate
Hi Philip, Earlier I manual dropped all the tables that didn't fix the problem Now used rake db:drop db:create db:migrate but still geting rake aborted message.. C:\Murali Rubby\demo\library>rake db:drop db:create db:migrate (in C:/Murali Rubby/demo/library) rake aborted! Mysql::Error: Specified key was too long; max key length is 767 bytes: CREATE UN IQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`) (See full trace by running task with --trace) So please provide some other Info to fix that... Thank you so much for your quick reply. -- 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 post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Beginner
On 29 January 2010 09:42, Karthikeyan wrote: > > goto http://rubyonrails.org , better get Agile Web Development With > Rails by Dave Thompson Make sure you get the latest revision of AWD. Also http://www.railstutorial.org/ though this will only take you so far as it is still in development. Colin > > On Jan 29, 12:39 pm, Chris Bautista wrote: >> Hello all! >> >> I was recommended by a buddy to check out Ruby on Rail. So here I am. >> >> Does anyone have any good websites for tutorials? > > -- > 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-t...@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner
goto http://rubyonrails.org , better get Agile Web Development With Rails by Dave Thompson On Jan 29, 12:39 pm, Chris Bautista wrote: > Hello all! > > I was recommended by a buddy to check out Ruby on Rail. So here I am. > > Does anyone have any good websites for tutorials? -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner to Ruby
csuper wrote: > I haven't read the book you bought. But Why's (poignant) Guide to > Ruby is a pretty good free beginners book. It is also pretty fun to > read. > > http://mislav.uniqpath.com/poignant-guide/ It's a fun read, but I didn't find it terribly useful for learning. I basically just taught myself from Programming Ruby. Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org -- 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 post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner to Ruby
I haven't read the book you bought. But Why's (poignant) Guide to Ruby is a pretty good free beginners book. It is also pretty fun to read. http://mislav.uniqpath.com/poignant-guide/ On Jan 16, 2:02 am, Akshay Nawale wrote: > Hello to all Ruby members, I am eager to learn Ruby for Rails.. > I just bought the book "Ruby For Rails" by David A. Black > Is it good enough for the beginner like me to start with this book > Please Suggest... -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner to Ruby
Akshay, Personally, I liked Ruby on Rails: Up and Running (http:// www.amazon.com/Ruby-Rails-Running-Bruce-Tate/dp/0596101325). The reviews on Amazon are mixed, but let me say it this way: as a stand- alone book, it will not teach you the in-depth aspects of Rails development. What it WILL do is let you, in an afternoon, fire through an entire book and build an application quickly. I love the Agile Web Development with Rails book. Absolutely love it. But it's a decently large book that does take some time to get through because it covers all the bases. If you read the RoR: Up and Running book, learn the Rails environment and how these apps work, then go back and read the Agile book to get a deeper understanding, I think you'll be in good shape. Just my $.02! Good luck and welcome to the RoR community. - Alan http://twitter.com/anachronistic -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner to Ruby
I started learning a little over a year ago. Although I have a long way to go, I can look back and see that creating an example app that was in the book (Agile Web Development with Rails, Third Edition), really helped me to learn what RoR can do. From there, I read through the details of the language while starting to build my own app. It's a slow process, learning while coding, and frustrating at times because it can take forever to figure out how to do the simplest thing BUT... slowly but surely, I'm learning. Whatever you decide to read, just stick with it. Good luck! On Jan 16, 2:02 am, Akshay Nawale wrote: > Hello to all Ruby members, I am eager to learn Ruby for Rails.. > I just bought the book "Ruby For Rails" by David A. Black > Is it good enough for the beginner like me to start with this book > Please Suggest... -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: beginner problem
Aldric Giacomoni wrote: > Guille San wrote: >> Hi, >> I´m starting using rails. I have one problem. I create a controller, the >> code is the next: >> class PlayersController < ApplicationController >> scaffold:player >> end > > "scaffold" is something that you use on the command line, not within > your code. > Delete the file in which your controller is. > Go on the command line, in the root of your rails application. > Type "ruby script/generate scaffold player name:string". Scaffold was a controller method in Rails 1.x. If you are following a tutorial that is having you use it, then you are following a seriously outdated tutorial. Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org -- 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 post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: beginner problem
Guille San wrote: > Hi, > I´m starting using rails. I have one problem. I create a controller, the > code is the next: > class PlayersController < ApplicationController > scaffold:player > end "scaffold" is something that you use on the command line, not within your code. Delete the file in which your controller is. Go on the command line, in the root of your rails application. Type "ruby script/generate scaffold player name:string". -- 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 post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner views
Okej! I suspected it would be done that way. Thank you for the time once again! On Dec 21, 2:24 pm, Colin Law wrote: > 2009/12/21 Manus : > > > Hey! > > > I'm a bit new to Rails and I wonder how one render both the new > > controller and the index on the same page. > > For example: > > > Guestbook > > (new) #post a new entry > > (index) #showing all posts > > > I do not want to go to a separate new page. > > There is nothing stopping you showing a form for entering a new record > on the same page as the index. The view erb file merely has to show > the form and the index. Use partials for the two sections so you can > use the same partials individually if you want just one or the other. > > 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Beginner needs help
Tried the suggestions from Sijo. Worked like a charm. Coool..! Thanks again everyone! //Peter -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner needs help
Thanks guys, I have been out of town a few days, thats why this late reply. I am using Rails 2.3.2 The book was published in 2006 so I guess the examples can be out of date. I ran into that when the book mentioned start-form-tag and end-form-tag... Took me a while to figure that out. Anyways, I am buildng all the examples from scratch, and so far I have not downloaded anything, so it could be a typo, even though I have checked the code several times... Tha last two suggestions I haven't tried yet, but I will. cheers, -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner needs help
> > class AuthorTest < Test::Unit::Testcase change the above to class AuthorTest < ActiveSupport::TestCase -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner needs help
> > class AuthorTest < Test::Unit::Testcase change the above to class AuthorTest < ActiveSupport::TestCase Sijo -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner needs help
He's using 2.3.2 from the errors.. So, did you create everything from scratch? Or, did you read a section in the book that said go to x website and download the incomplete or complete samples and you are working from those? If you are working from samples, the samples are probably not using the same RoR version you are. That's the very first question I'd answer. Most books and source files that go with those books are out of date already. -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner needs help
What version of Rails are you using? On Jul 2, 1:56 pm, Peter Hermansson wrote: > Hi, I am trying to follow the book 'Beginning Ruby on Rails e-commerce' > examples. > > When I come to unit testing I get an error message: > C:/Ruby/bin/ruby.exe -I"lib;test" > "C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/rake_test_loader.rb" > "test/unit/author_test.rb" "test/unit/helpers/about_helper_test.rb" > C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:440:in > `load_missing_constant': uninitialized constant Test::Unit::Testcase > (NameError) > > My test/unit/author_test.rb looks like this: > > require File.dirname(__FILE__) + ' /../test_helper' > > class AuthorTest < Test::Unit::Testcase > fixtures :authors > def test_name > author=Author.create(:first_name => 'Joel', > :last_name => 'Spolsky') > > assert_equal 'Joel Spolsky', author.name > end > end > > Why do I get the error message ? > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: beginner
On May 24, 6:29 pm, Freddy Andersen wrote: > if params[:checkbox] > > This checks if that params is true(true/false, 1/0) both 1 and 0 are true in ruby :-) If you are doing this by hand you will need to compare params [:checkbox] to the value that gets submitted. if you are using the check_box helper then by default the value will be "0" or "1" (strings, not integers). If you are using check_box_tag or crafting the html by hand then it is slightly more troublesome as if the check box is not ticked there will be no value in the params hash. If you are using the check_box helper it might be appropriate to just pass the appropriate part of the params hash to update_attributes. Fred or not, but how > did you do you checkbox code? If its just a form_for .. do |f| > f.checkbox(:checkbox) you should be ok. --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: beginner
if params[:checkbox] This checks if that params is true(true/false, 1/0) or not, but how did you do you checkbox code? If its just a form_for .. do |f| f.checkbox(:checkbox) you should be ok. --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: beginner question
Frederick Cheung wrote: > Don't think xcode does anything with rails at all I'm pretty sure you're correct Fred. Installing the developer tools (including Xcode) also install Ruby and Rails, along with other useful developer related things like gcc, cvs, Subversion, etc. But, other than that Xcode itself doesn't interact with Rails. I do have a couple of recommendations though. Before you do anything else with updating, first update Rubygems with: sudo gem update --system Then your should be safe to go ahead and update any gems you like, including Rails. I'm not sure if this matters, but I don't really use the gem update command, other than to update Rubygems itself. Instead I just use the gem install command to install updated versions: sudo gem install rails -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: beginner question
Thank you for that information Fred! On May 21, 1:38 am, Frederick Cheung wrote: > On May 20, 9:39 pm, Calvin wrote: > > > Hello, > > > I am using rails 1.2.3 that came with my mac Xcode installation. If I > > update rails with: > > > sudo gem update rails > > > will the latest version of rails cause a conflict with Xcode? > > Don't think xcode does anything with rails at all > > Fred > > > > > Thanks for your time, > > > Calvin- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: beginner question
On May 20, 9:39 pm, Calvin wrote: > Hello, > > I am using rails 1.2.3 that came with my mac Xcode installation. If I > update rails with: > > sudo gem update rails > > will the latest version of rails cause a conflict with Xcode? > Don't think xcode does anything with rails at all Fred > Thanks for your time, > > Calvin --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner: what to do after adding an association in a model?
So building on that example, you should add a column person_id to the address table. Rails will infer the foreign key based on rails model names. U can also specify the actual column by passing :foreign_key into belongs_to macro. Roman On Mar 12, 6:22 am, Ar Chron wrote: > The associations you create in a model have to be backed up by the > appropriate fields in the DB. > > For example: > > class Person > has_many :addresses > > class Address > belongs_to :person > > should be a model representation of the relationship inherent in the > database (the two really go hand-in-hand). > > if: > > Table people > id:integer > first_name:string > last_name:string > > Table address > id:integer > person_id:integer > line1:string > line2:string > city:string > state:string > postal_code:string > > has_many :addresses tells Rails that for a given person, it can use that > person id field to retrieve address records (those whose person_id > matches the current person id value). Similarly, from an address, Rails > can get back to the person record by following the person_id on the > address. > > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner: what to do after adding an association in a model?
The associations you create in a model have to be backed up by the appropriate fields in the DB. For example: class Person has_many :addresses class Address belongs_to :person should be a model representation of the relationship inherent in the database (the two really go hand-in-hand). if: Table people id:integer first_name:string last_name:string Table address id:integer person_id:integer line1:string line2:string city:string state:string postal_code:string has_many :addresses tells Rails that for a given person, it can use that person id field to retrieve address records (those whose person_id matches the current person id value). Similarly, from an address, Rails can get back to the person record by following the person_id on the address. -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner: what to do after adding an association in a model?
Does that mean I have to write a custom migration for it, the only automated migrations I can find are for adding/removing columns (AddXXXtoYYY). Is there something like AddHasAndBelongsToManyModelXToModelY? Dave. 2009/3/12 Frederick Cheung : > On Mar 12, 6:05 am, neerolyte wrote: >> I've looked at a bunch of tutorials and don't really understand what >> is supposed to happen after I add an association (belongs_to, has_many >> etc) to both sides of a relationship. >> >> A lot of the tutorials just add the associations and move on as if >> that's it, but when I add the association nothing has changed in the >> db (which makes sense because at this point I've only changed code). >> Is there a command I'm supposed to run to look at all the >> relationships and add tables/columns for relationships that are >> missing them? or am I supposed to manually create the table? > > You're suppose to use migrations to add columns or create tables (see > http://guides.rubyonrails.org/migrations.html ) > > Fred --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner: what to do after adding an association in a model?
I dont think so you need to do any thing manually with the db.. Just use the association by using dot operator. Regards Rabia On Thu, Mar 12, 2009 at 11:05 AM, neerolyte wrote: > > I've looked at a bunch of tutorials and don't really understand what > is supposed to happen after I add an association (belongs_to, has_many > etc) to both sides of a relationship. > > A lot of the tutorials just add the associations and move on as if > that's it, but when I add the association nothing has changed in the > db (which makes sense because at this point I've only changed code). > Is there a command I'm supposed to run to look at all the > relationships and add tables/columns for relationships that are > missing them? or am I supposed to manually create the table? > > > > --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner: what to do after adding an association in a model?
On Mar 12, 6:05 am, neerolyte wrote: > I've looked at a bunch of tutorials and don't really understand what > is supposed to happen after I add an association (belongs_to, has_many > etc) to both sides of a relationship. > > A lot of the tutorials just add the associations and move on as if > that's it, but when I add the association nothing has changed in the > db (which makes sense because at this point I've only changed code). > Is there a command I'm supposed to run to look at all the > relationships and add tables/columns for relationships that are > missing them? or am I supposed to manually create the table? You're suppose to use migrations to add columns or create tables (see http://guides.rubyonrails.org/migrations.html ) Fred --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner Layouts and Partials question
sa 125, This paper (Modular Page Assembly in Rails) helps a lot: http://www.railsdev.ws/blog/3/modular-page-assembly-in-rails/ Cheers, Sazima On Dec 23, 12:38 pm, sa 125 wrote: > Hello - very new to rails and MVC, I'm trying to figure out how > layouts/partials co-exist. My basic layout (application.html.erb) looks > like this: > > > > <%= render :partial => "main/header" %> > > <%= render => :partial => "main/menu" %> > <%= render => :partial => @partial %> > > > > > and my MainController is: > > class MainController > > def index > @partial = "main/home" > end > > end > > Now, I found that I have to create an index.html.erb file that's > identical to the application.html.erb file, or nothing works (neither > can exist without the other). I'm trying to understand what I'm doing > wrong -- obviously I need some index action in my controller, but I'd > like to just maintain one layout file and nothing else.. I'm obviously > missing something big here, so any clarifications will be great :) > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner Layouts and Partials question
> in the view (app/views/people/index.html.erb): > > <% content_for :title do -%> > Listing People > <% end -%> > > > > First Name > Last Name > > <%= render :partial => "people", :collection => @people %> > > in the partial (app/views/people/_people.html.erb): > > > > <%= h person.first_name %> > <%= h person.last_name %> > > > > > I made sure I had data available for these people (using > script/console), but I got an error rendering this partial: > > undefined local variable or method 'person' for # > > in app/views/people/_people.html.erb > OK, I figured out my mistake - when creating the partial, I called it "_people.html.erb" instead of "_person.html.erb", so the rails engine probably didn't know what to look for. Also needed to change the call to render from <%= render :partial => "people" %> to <%= render :partial => "person"...%> I would like to know how to override this behavior so that I could call the partial and the collections however I want. Thanks to everyone who helped on this post! -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner Layouts and Partials question
> I realize the partial doesn't recognize the person object, but I thought > rails handled the conversion between the collection @people of the view > to the iteration in the partial. So.. I'm not sure what I might be doing > wrong. Help is very appreciated - thanks! i don't see an iteration. try for person in people do > <%= h person.first_name %> <%= h person.last_name %> end --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner Layouts and Partials question
These were all really helpful -- I really appreciate the depth of the responses. I now only have a problem with using a collection in rendering a partial. I think I followed the exact rules, but here is what I did anyway: The layout (app/views/layouts/application.html.erb): ... <%= yield :title %> <%= yield %> ... the controller (app/controllers/people/people_controller.rb): class PeopleController < ApplicationController layout "application" # default, but specified anyway def index @people = Person.find(:all) end end in the view (app/views/people/index.html.erb): <% content_for :title do -%> Listing People <% end -%> First Name Last Name <%= render :partial => "people", :collection => @people %> in the partial (app/views/people/_people.html.erb): > <%= h person.first_name %> <%= h person.last_name %> I made sure I had data available for these people (using script/console), but I got an error rendering this partial: undefined local variable or method 'person' for # in app/views/people/_people.html.erb I realize the partial doesn't recognize the person object, but I thought rails handled the conversion between the collection @people of the view to the iteration in the partial. So.. I'm not sure what I might be doing wrong. Help is very appreciated - thanks! -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner Layouts and Partials question
You may also want to read the getting started guide (and others) on http://guides.rubyonrails.org - Ryan Bigg Freelancer http://frozenplague.net On 24/12/2008, at 5:50 AM, sa 125 wrote: > > Those were really helpful posts -- I think I got the general idea, in > which I should specify in the controller which layout it should belong > to, and then in the layout file use <%= yield %> to render these > views. > I'll keep playing with it and see what comes up. > > Thanks! > > -- > 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 post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner Layouts and Partials question
Robert Walker wrote: > layout by first looking in app/layouts/ for a layout template named Correction app/views/layouts/ -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner Layouts and Partials question
sa 125 wrote: > Those were really helpful posts -- I think I got the general idea, in > which I should specify in the controller which layout it should belong > to, and then in the layout file use <%= yield %> to render these views. > I'll keep playing with it and see what comes up. > > Thanks! Take this example: app/controllers/people_controller.rb: class PeopleController < ApplicationController # layout 'custom' # GET /people # GET /people.xml def index @people = Person.find(:all) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @people } end end end app/views/layouts/application.html.erb: http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en"> My Application Header in Application layout <%= yield %> Footer in layout app/views/layouts/people.html.erb: http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en"> My Application Header in People layout <%= yield %> Footer in layout app/views/layouts/custom.html.erb: http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en"> My Application Header in Custom layout <%= yield %> Footer in layout app/views/people/index.html.erb: Listing people First name Last name <% for person in @people %> <%= render :partial => 'list' %> <% end %> <%= link_to 'New person', new_person_path %> Notice in this example that the first line in the people_controller is commented out. So in this case Rails begins searching for an appropriate layout by first looking in app/layouts/ for a layout template named people.html.erb. If it exists Rails will use it automatically. If it does not exist then Rails looks for a template named application.html.erb. If that file exists it will be applied to any controller that does not specify a specific layout to use. In all cases if the layout is provided (by uncommenting line #1 in this example controller) it will look for a template with the given name (custom.html.erb) in this example. I also provided a contrived partial in the app/views/people/index.html.erb template to show when how how partials might be used. There is also a method called "content_for" I'll leave that up to you to investigate, but this can also be very useful when dealing with layouts and partials. -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner Layouts and Partials question
Those were really helpful posts -- I think I got the general idea, in which I should specify in the controller which layout it should belong to, and then in the layout file use <%= yield %> to render these views. I'll keep playing with it and see what comes up. Thanks! -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner Layouts and Partials question
Here it goes A layout is like the container for the content(.. view) relating to your actions. When an action is called, the action renders its view. For example, the person controllers index action will look for app/ views/person/index.html.erb. It also looks for the layout it should render the view in. You can define the layout to use either in the controller (layout 'application' in your case) or put in in application.rb, which will then define a global default layout. You've got the right idea with the erb you posted. You can render partials in layouts, but for the action to render it's view in the layout, you need to put <%= yield %>. The entire contents of the actions's view will get rendered there. Your layout, application.html.erb should be residing in the app/views/ layout directory. You should add "layout 'application'" to your controller, add <%= yield %> to the layout, create views for your actions and try it out. Your views should render inside your layout. I hope that gives you some idea of how views and layouts interact. - John On Dec 23, 8:38 am, sa 125 wrote: > Hello - very new to rails and MVC, I'm trying to figure out how > layouts/partials co-exist. My basic layout (application.html.erb) looks > like this: > > > > <%= render :partial => "main/header" %> > > <%= render => :partial => "main/menu" %> > <%= render => :partial => @partial %> > > > > > and my MainController is: > > class MainController > > def index > @partial = "main/home" > end > > end > > Now, I found that I have to create an index.html.erb file that's > identical to the application.html.erb file, or nothing works (neither > can exist without the other). I'm trying to understand what I'm doing > wrong -- obviously I need some index action in my controller, but I'd > like to just maintain one layout file and nothing else.. I'm obviously > missing something big here, so any clarifications will be great :) > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner Layouts and Partials question
right: you need an index-file for your index-action (actions and views pair up) wrong: it has not to be identical to the layout-file. try to put <%= yield %> into your layout instead of <%= render => :partial => @partial %> and change your index to Hello it's <%= Time.now %> in your controller just leave it like this def index end now, if you want to render a partial, do so by saying it for example in your view. if you put render :partial => foo in your controller, then by default layout => false is set. maybe i'm even mistaken somewhere, but anyhow i hope i could help. my suggestion: get hold of some rails basics. --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner: helper vs model
Rob Biedenharn wrote: > On Nov 28, 2008, at 1:51 PM, Scott Peterson wrote: >> So, I've generated a player_admin controller and pointed it to my >> object using debug(), which didn't show fullname as an attribute. >> end > You really want to have this in your Player model. It will look > almost the same: > > class Player >def fullname > self.first_name + " " + self.last_name >end > end > > or perhaps: > > class Player >def fullname > "#{self.first_name} #{self.last_name}" >end > end > Absolutely right. I want a single place which defines how I build "fullname", so when I add title, middle name, whatever, it just works everywhere I display. >> funadmentally >> wrong with how I'm thinking about Ruby objects, that in the Player >> model >> wasn't really an appropriate place to try that? >> >> Thank you. > > How did the method look when you tried to define it within your Player > model? If you still tried to refer to @player rather than self, that > may be your mental hurdle. You're defining a new attribute of a > model. The rest of the system shouldn't care if the storage behind > the model changes to hold the fullname and the other methods become: > > class Player >def first_name > self.fullname.split(' ').first >end >def last_name > self.fullname.split(' ').last >end > end > > (NOTE: I'm not suggesting that this should happen, but only that the > rest of the application can continue to reference @player.first_name, > @player.last_name, or @player.fullname without having to know what > really sits behind the model.) > > -Rob > > Rob Biedenharnhttp://agileconsultingllc.com > [EMAIL PROTECTED] Thanks a million for the response. Not sure what I did yesterday. I'm pretty sure I wasn't referring to "@player", as I was in the Player model object. Some foolish typo, I imagine. Glad to hear that I had the right idea though. -- 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 post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner: helper vs model
On Nov 28, 2008, at 1:51 PM, Scott Peterson wrote: > Just learning the framework. I apologize if this is in the worng > forum. > I looked around for something like "Beginner's Questions" but didn't > see > it. > > I'm building a simple application which will let players register > for an > event. > > So, I've generated a player_admin controller and pointed it to my > players table. Worked great, I'm off and running. > > After learning about hashing the password, I decided I might like to > add > a convenience method to the Player (attached) which would give > fullname. > My ultimate goal of this is to list the players, obviously. > > In the player_admin/show view, I tried <%= @player.fullname %>, got an > error which said fullname not defined. I also just dumped the player > object using debug(), which didn't show fullname as an attribute. > > I also tried it as a no-param method [i.e., fullname() ], without > luck. > > After puzzling a while, I came across the notion of helpers, and > decided > to try the method in the player_admin_helper: > > def fullname > @player.first_name + " " + @player.last_name > end You really want to have this in your Player model. It will look almost the same: class Player def fullname self.first_name + " " + self.last_name end end or perhaps: class Player def fullname "#{self.first_name} #{self.last_name}" end end > > > Worked like a charm. I kind of understand, it's because the show view > was invoked by the player_admin controller, so he has access to the > player_admin_helper, but that won't help me when I'm off in some other > part of the application. > > I don't understand where I went wrong when just trying to get a > similar > method directly in the player object. Is there something > funadmentally > wrong with how I'm thinking about Ruby objects, that in the Player > model > wasn't really an appropriate place to try that? > > Thank you. How did the method look when you tried to define it within your Player model? If you still tried to refer to @player rather than self, that may be your mental hurdle. You're defining a new attribute of a model. The rest of the system shouldn't care if the storage behind the model changes to hold the fullname and the other methods become: class Player def first_name self.fullname.split(' ').first end def last_name self.fullname.split(' ').last end end (NOTE: I'm not suggesting that this should happen, but only that the rest of the application can continue to reference @player.first_name, @player.last_name, or @player.fullname without having to know what really sits behind the model.) -Rob Rob Biedenharn http://agileconsultingllc.com [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner: "NameError - uninitialized constant" when I create a model object
On Nov 28, 2:57 pm, packat <[EMAIL PROTECTED]> wrote: > It is in app/models > > On Nov 28, 9:28 am, Frederick Cheung <[EMAIL PROTECTED]> > wrote: > > > On Nov 28, 1:49 pm, packat <[EMAIL PROTECTED]> wrote:> My first Rails > > example using model and I got this NameError: > > > NameError in VandaController#att > > > uninitialized constant VandaController::Compute > > > Is the model in compute.rb in app/models or lib ? > > It is in app/models. > The important thing was whether the file was called compute.rb > I am following a book "Beginning Ruby on Rails" by Steven Holzner. > That book may be based on older version. Mine is 1.8.6 The important thing would be the rails version, not the ruby version. > > and now get a different error: > > ActiveRecord::StatementInvalid in VandaController#att > Mysql::Error: Table 'orchids.computes' doesn't exist: SHOW FIELDS FROM > `computes` > > Apparently, a schema is created for Compute and Ruby thought ther is a > Compute table in the database. > So this is not helping any. It would have created a migration to add that table but it would not have run it. You can run it with rake db:migrate Fred > > > Fred > > Thanks Fred --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner: "NameError - uninitialized constant" when I create a model object
It is in app/models On Nov 28, 9:28 am, Frederick Cheung <[EMAIL PROTECTED]> wrote: > On Nov 28, 1:49 pm, packat <[EMAIL PROTECTED]> wrote:> My first Rails example > using model and I got this NameError: > > NameError in VandaController#att > > uninitialized constant VandaController::Compute > > Is the model in compute.rb in app/models or lib ? > It is in app/models. I am following a book "Beginning Ruby on Rails" by Steven Holzner. That book may be based on older version. Mine is 1.8.6 After posting the question, I blindly tried running "ruby script/generate model compute" and now get a different error: ActiveRecord::StatementInvalid in VandaController#att Mysql::Error: Table 'orchids.computes' doesn't exist: SHOW FIELDS FROM `computes` Apparently, a schema is created for Compute and Ruby thought ther is a Compute table in the database. So this is not helping any. > Fred Thanks Fred --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner: "NameError - uninitialized constant" when I create a model object
On Nov 28, 1:49 pm, packat <[EMAIL PROTECTED]> wrote: > My first Rails example using model and I got this NameError: > NameError in VandaController#att > uninitialized constant VandaController::Compute > Is the model in compute.rb in app/models or lib ? Fred > Same code works fine if I don't create the Compute object. > What did I do wrong? > > Here is the Controller > class VandaController < ApplicationController > def att > @compute = Compute.new > @data1 = @compute.cmpt > end > end > > Here is the Model > class Compute > def cmpt > return 5 > end > end > > And here is the view > > > Model > > > reading data from a model > > > Fetch : <%= @data1 %> from Compute model. > > > --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Beginner Question: Formatted Text Data -> Hash -> Database.
I'll be interested to see what responses you get, but I can't think of a more efficient way. I'd try something like: my_file.each_line do |line| if line ~= /$User/ and this_user.username.length > 0 then if this_user.save then puts("Saved user #{this_user.username}") else puts("Problem saving #{this_user.username}!:\n#{this_user.errors}") end this_user = User.new end attribute, val = line.split(/:\s*/) this_user.send(attribute.lower, val) end That's air-code obviously--may be wildly off... -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Jisho Sent: Thursday, September 11, 2008 10:50 AM To: Ruby on Rails: Talk Subject: [Rails] Beginner Question: Formatted Text Data -> Hash -> Database. I have a text document that has formatted data in it, and I am attempted to determine the best way to parse the data to break it up into hashes that I can then write to my databases. I suppose my issue is determining where to tell Ruby to STOP reading in data to write into the database. The file would be similar to this: User: Username Phone: Phone number Address: Address Comments: Comments Data1: Data Data2: Data Data3: Data User: Username Phone: Phone number Address: Address Comments: Comments Data1: Data Data2: Data User: Username Phone: Phone number Address: Address Comments: Comments Data1: Data Data2: Data It's not that difficult to chomp the \n and use a split to create a hash in a loop, but how do tell Ruby to start a new database write process if it hits a new "user" key value? Should I write a case statement to check each line for a "user" key and use that line to call a new instance of my database class/method? Is there a faster or more efficient way? --~--~-~--~~~---~--~~ 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@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---