[Rails] question about using link_to in template and in console

2019-04-15 Thread Robert Phillips
I have a question about using link_to in template and in console Say I do rails new blah, I make a model called User, I make a table users, each user has a field called 'name'. I have resources :users, in config/routes.rb And I add some users. in template, I can do <% @z=User.find_by(name

Re: [Rails] Is it possible to reference welcome#index, in the routes file?

2019-03-08 Thread Robert Phillips
On Friday, 8 March 2019 14:19:01 UTC, Colin Law wrote: > > On Fri, 8 Mar 2019 at 13:05, Robert Phillips > > wrote: > > ... > > I don't mean to sound patronizing > > Not sure you have succeeded in that. > > > ... > > Also you were trying t

Re: [Rails] Is it possible to reference welcome#index, in the routes file?

2019-03-08 Thread Robert Phillips
On Friday, 8 March 2019 13:02:46 UTC, Walter Lee Davis wrote: > > > > On Mar 8, 2019, at 7:40 AM, Colin Law > > wrote: > > > > On Fri, 8 Mar 2019 at 12:19, Robert Phillips > > > wrote: > >> > >> > >> > >> On Frida

Re: [Rails] Is it possible to reference welcome#index, in the routes file?

2019-03-08 Thread Robert Phillips
On Friday, 8 March 2019 12:41:34 UTC, Colin Law wrote: > > > > Have you got a controller called WelcomeController? If not then what > is the name of the controller with method index? > > Colin > You understand that there's a controller I'm trying to reference but that's about it. I don't t

Re: [Rails] Is it possible to reference welcome#index, in the routes file?

2019-03-08 Thread Robert Phillips
On Friday, 8 March 2019 12:07:16 UTC, Colin Law wrote: > > > You can reference any controller/action in the routes. Welcome#index > is no different to any other. Reference it exactly the same way as > you would reference any controller#action. > Would be all lowercase. (as with all controll

[Rails] Is it possible to reference welcome#index, in the routes file?

2019-03-08 Thread Robert Phillips
Is it possible to reference welcome#index, in the routes file? e.g. suppose you create a rails program, so then you do ralsi server you get the welcome page come up. but the routes file is blank. The welcome controller hasn't been referenced explicitly. i'd like to reference it explicitly. Sa

Re: [Rails] Why is id off by one or defined different in edit vs in update?

2018-06-08 Thread Robert Phillips
On Saturday, 9 June 2018 02:43:13 UTC+1, jim wrote: > > > >> @bottle=Bottle.all[params[:id].to_i] #:id==0 >> > > Your error is on these lines. .. > > Yeah I got it now, thanks, I fixed all my actions In the edit action, you should be getting the id of the bottle so you can > find th

Re: [Rails] Why is id off by one or defined different in edit vs in update?

2018-06-08 Thread Robert Phillips
On Friday, 8 June 2018 23:03:51 UTC+1, Hassan Schroeder wrote: > > On Fri, Jun 8, 2018 at 12:54 PM, Robert Phillips > > wrote: > > > def edit > > # http://127.0.0.1:3000/bottles/0/edit :id==0 > > Where in the world are you getting this id of 0

[Rails] Why is id off by one or defined different in edit vs in update?

2018-06-08 Thread Robert Phillips
why is id off by one or defined different in edit vs in update? I will explain what I mean I have a controller called Bottles and a model Bottle My config\routes.rb file has the line- resources :bottles I have this controller class BottlesController < ApplicationController def index end

[Rails] What, if any, partial reload, does creating a table from the rails console do?

2018-03-18 Thread Robert Phillips
What, if any, partial reload, does creating a table from the rails console do? I'll explain what I mean C:\rubytest\proj>rails new abc1 .. C:\rubytest\proj>cd abc1 C:\rubytest\proj\abc1>cd app\models C:\rubytest\proj\abc1\app\models>notepad blah.rb C:\rubytest\proj\abc1\app\m

Re: [Rails] How can I get this create_table statement on one line?

2018-03-18 Thread Robert Phillips
On Sunday, 11 March 2018 14:36:30 UTC, Walter Lee Davis wrote: > > > . > > Here's a multi-line block format migration method: > > create_table :friendly_id_slugs do |t| > t.string :slug, :null => false > t.integer :sluggab

[Rails] Re: Why ApplicationRecord

2018-03-10 Thread Robert Phillips
On Sunday, 11 March 2018 02:39:43 UTC, Robert Phillips wrote: > > On Friday, 9 March 2018 14:58:23 UTC, fugee ohu wrote: > >Why create an ApplicationRecord class inheriting from ActiveRecord::Base > and then have all models inherit from ApplicationRecord instead of >

[Rails] Re: Why ApplicationRecord

2018-03-10 Thread Robert Phillips
On Friday, 9 March 2018 14:58:23 UTC, fugee ohu wrote: >Why create an ApplicationRecord class inheriting from ActiveRecord::Base and then have all models inherit from ApplicationRecord instead of ActiveRecord::Base ? I know a guy that doesn't use rails generate controller or rails generate mod

Re: [Rails] How can I get this create_table statement on one line?

2018-03-10 Thread Robert Phillips
:42 AM, Robert Phillips > > wrote: > > > I can't get a create_table statement onto one line > > > > irb(main):019:0> ActiveRecord::Migration.create_table :wers { |t| > t.string > > :name } > > SyntaxError: (irb):19: syntax error, unexpected &#

[Rails] How can I get this create_table statement on one line?

2018-03-09 Thread Robert Phillips
If I go to rails console I can't get a create_table statement onto one line irb(main):019:0> ActiveRecord::Migration.create_table :wers { |t| t.string :name } SyntaxError: (irb):19: syntax error, unexpected '{', expecting end-of-input Migration.create_table :wers { |t| t.string :name } I can

Re: [Rails] command line erb?

2018-02-25 Thread Robert Phillips
On Sunday, 25 February 2018 18:18:37 UTC, Mauro Locatelli wrote: > > Ok I understand, sorry but I never need a thing such these so I can't help > you. > > Mauro > Yes ok you couldn't help with that but I found the answer eventually, I mentioned it in my post, so it's ok. Thanks.. -- You re

Re: [Rails] command line erb?

2018-02-25 Thread Robert Phillips
February 2018 17:49:07 UTC, Mauro Locatelli wrote: > > rails console? > > Il 25 feb 2018 6:46 PM, "Robert Phillips" > ha scritto: > >> >> >> On Sunday, 25 February 2018 17:29:36 UTC, Hassan Schroeder wrote: >>> >>> On Sun, Feb 25, 2018 at 9:

Re: [Rails] command line erb?

2018-02-25 Thread Robert Phillips
On Sunday, 25 February 2018 17:29:36 UTC, Hassan Schroeder wrote: > > On Sun, Feb 25, 2018 at 9:08 AM, Robert Phillips > > wrote: > > > Is there a command line ERB? > > I suspect you're looking for "irb" -- Interactive Ruby. > No, ERB is not IRB

[Rails] command line erb?

2018-02-25 Thread Robert Phillips
Hi Is there a command line ERB? I've heard of one but if I look for an ERB executable I can't see one I am in windows, I don't know if there is one in linux but not in windows? if perhaps the issue is different distros of ruby , I don't know which distro I have / how to find out. Thanks --

Re: [Rails] trying to reset id from console

2018-02-11 Thread Robert Phillips
On Saturday, 23 December 2017 16:41:57 UTC, Hassan Schroeder wrote: > > On Sat, Dec 23, 2017 at 6:02 AM, Robert Phillips > > wrote: > > As Walter already pointed out, you shouldn't care about the content > of the id field, but ... > > > I get this er

[Rails] Re: I can't set the title of a page no matter what I have tried to put in my .html.erb file

2018-01-17 Thread Robert Phillips
ls.org/layouts_and_rendering.html#using-the-content-for-method > > HTH > John > > > On Saturday, January 13, 2018 at 7:18:23 PM UTC-5, Robert Phillips wrote: >> >> I can't set the title of a page no matter what I have tried to put in my >> .html.erb file

Re: [Rails] I can't set the title of a page no matter what I have tried to put in my .html.erb file

2018-01-13 Thread Robert Phillips
On Sunday, 14 January 2018 00:46:39 UTC, Hassan Schroeder wrote: > > On Sat, Jan 13, 2018 at 4:18 PM, Robert Phillips > > wrote: > > > So, what it is doing is rails is taking its own template then it dumps > my template into its > > Yep, that's the way

[Rails] I can't set the title of a page no matter what I have tried to put in my .html.erb file

2018-01-13 Thread Robert Phillips
I can't set the title of a page no matter what I have tried to put in my .html.erb file >rails new testblah >bundle install <-- not necessary here but anyway. >rails generate controller abc def > rails s I go to http://127.0.0.1:3000 and I see the default template view .\app\views\abc

Re: [Rails] Problem using render text in basic rails application

2018-01-07 Thread Robert Phillips
On Sunday, 7 January 2018 22:34:10 UTC, Phil wrote: > > > render text: is deprecated. Stick with render plain: . > > > Phil > > Thanks -- 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 emai

[Rails] Problem using render text in basic rails application

2018-01-07 Thread Robert Phillips
It works fine as far as this C:\blah>rails new test1 C:\blah\test1>rails server I edit application_controller.rb I add a function called hello def hello render plain: "aasdf" end I edit the routes.rb file I add this line into the existing procedure within routes.rb root 'application#h

[Rails] trying to reset id from console

2017-12-23 Thread Robert Phillips
I've got the program in chapter 2. is there anything i can type in the console to reset the id? I can do e.g. User.delete_all and delete all users, but if a new user is then created it doesn't have an id of 1 'cos the id doesn't reset. this User.reset_primary_key doesn't work either. Notice