Re: [Rails] button_to question

2016-11-15 Thread Colin Law
On 15 Nov 2016 11:02 p.m., "Joe Guerra"  wrote:
>
> OK, maybe I just need to see an example of how to call a method from a
button-to button.

No you need to show us what you have done and tell us what is not working.
Which bit is failing? Is it getting to your controller action? Is it
failing running the action? Is it not rendering the next view correctly? Or
what. Show us the specific bit of code that is not working.

Colin

>
>
> On Nov 16, 2016 1:22 AM, "Colin Law"  wrote:
>>
>> On 15 November 2016 at 16:55, Joe Guerra  wrote:
>>>
>>> ok, it's looking for a view at that route (or path), but my method says
to render a partial file (modal dialog page).
>>>
>>> Hmmm, did I miss something?
>>
>>
>> Without more information it is impossible to say.
>>
>> Colin
>>
>>>
>>>
>>> On Tuesday, November 15, 2016 at 2:35:31 AM UTC-5, Colin Law wrote:

 On 14 November 2016 at 23:17, Joe Guerra  wrote:
>
> Hi,
>
> I'm trying to run a method in one of my controllers using a button_to
command.  How is this accomplished?
>
> So far, I've got <%= button_to "Add to Cart", action: "add_to_cart"
%> in my products page
>
> I defined a add_to_cart in my product controller, and created a route
for it.
>
> Am I on the right track?  Will it execute code in that method in that
controller?


 Try it and see, that would be a lot quicker than asking here. If it
doesn't then look in log/development.log and/or the server terminal window
to get a clue as to why not.  When setting the route don't forget that
button_to will use POST.

 Colin

>
>
> Thanks,
> Joe
>
> --
> You received this message because you are subscribed to the Google
Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it,
send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/28e7bbb6-bd2c-4661-a5e3-8663135aef27%40googlegroups.com
.
> For more options, visit https://groups.google.com/d/optout.


>>> --
>>> 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/25d8e39f-de0a-447c-be46-99c249a16b90%40googlegroups.com
.
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> --
>> 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%3D0gLvmTds6dDKU%3D%3DK%3DAHybyG2hcuJPa-0A46cDmY2sPXO1jg%40mail.gmail.com
.
>>
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> 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/CAOFgAM%3Dgguwq1qCrxMf8hzir0RXVarv1oD00FQDR5%2BgT3E3v5Q%40mail.gmail.com
.
>
> For more options, visit https://groups.google.com/d/optout.

-- 
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%3D0gLtzmFngn5r49NLSoVhKVp28Xf2FxYmZiYa%3DEeeT8Jb4JA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Table already exists error

2016-11-15 Thread eye0rama


Hi all, 

I have been learning Rails by working through Carneiro and Barazi's 
*Beginning Rails 3*. This has went well despite the fact that I am using 
Rails 4.2.6. I hit a little snag when in chapter 5, which goes over 
associations, I tried to create a has_many association between a user and 
that user's articles, specifically in the code that is supposed to sort the 
user's articles first by order of creation, and then by alphabetical order. 
I fixed this problem, with a little help from the Ruby Talk mailing list, 
with a lambda scope block, as follows in app/models/user.rb: 


class User < ActiveRecord::Base 
 has_one :profile
 has_many :articles, -> { order 'published_at DESC, title ASC' } 
:dependent => :nullify
end

This seemed to work, so I went through the steps listed again, taking a 
stab that I could overwrite everything rather than just starting over.  
When I ran rake db:migrate, I got the following error:

== 20161114230702 CreateArticlesCategories: migrating 
=
-- create_table(:articles_categories, {:id=>false})
rake aborted!
StandardError: An error has occurred, this and all later migrations 
canceled:

SQLite3::SQLException: table "articles_categories" already exists: CREATE 
TABLE "articles_categories" ("article_id" integer, "category_id" integer) 
/home/john/src/ror/blog/db/migrate/20161114230702_create_articles_categories.rb:3:in
 
`change'
ActiveRecord::StatementInvalid: SQLite3::SQLException: table 
"articles_categories" already exists: CREATE TABLE "articles_categories" 
("article_id" integer, "category_id" integer) 
/home/john/src/ror/blog/db/migrate/20161114230702_create_articles_categories.rb:3:in
 
`change'
SQLite3::SQLException: table "articles_categories" already exists
/home/john/src/ror/blog/db/migrate/20161114230702_create_articles_categories.rb:3:in
 
`change'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

I did some poking around in the rails console, and running: 
category.articles.empty?

Returned: NameError: undefined local variable or method `category' for 
main:Object

Is there a way I can fix this without just deleting everything and starting 
over?

-- 
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/45dd619d-5519-4ca9-945c-4b292f056fd1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] button_to question

2016-11-15 Thread Joe Guerra
OK, maybe I just need to see an example of how to call a method from a
button-to button.

On Nov 16, 2016 1:22 AM, "Colin Law"  wrote:

> On 15 November 2016 at 16:55, Joe Guerra  wrote:
>
>> ok, it's looking for a view at that route (or path), but my method says
>> to render a partial file (modal dialog page).
>>
>> Hmmm, did I miss something?
>>
>
> Without more information it is impossible to say.
>
> Colin
>
>
>>
>> On Tuesday, November 15, 2016 at 2:35:31 AM UTC-5, Colin Law wrote:
>>>
>>> On 14 November 2016 at 23:17, Joe Guerra  wrote:
>>>
 Hi,

 I'm trying to run a method in one of my controllers using a button_to
 command.  How is this accomplished?

 So far, I've got <%= button_to "Add to Cart", action: "add_to_cart" %>
 in my products page

 I defined a add_to_cart in my product controller, and created a route
 for it.

 Am I on the right track?  Will it execute code in that method in that
 controller?

>>>
>>> Try it and see, that would be a lot quicker than asking here. If it
>>> doesn't then look in log/development.log and/or the server terminal window
>>> to get a clue as to why not.  When setting the route don't forget that
>>> button_to will use POST.
>>>
>>> Colin
>>>
>>>

 Thanks,
 Joe

 --
 You received this message because you are subscribed to the Google
 Groups "Ruby on Rails: Talk" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to rubyonrails-ta...@googlegroups.com.
 To post to this group, send email to rubyonra...@googlegroups.com.
 To view this discussion on the web visit https://groups.google.com/d/ms
 gid/rubyonrails-talk/28e7bbb6-bd2c-4661-a5e3-8663135aef27%40
 googlegroups.com
 
 .
 For more options, visit https://groups.google.com/d/optout.

>>>
>>> --
>> 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/ms
>> gid/rubyonrails-talk/25d8e39f-de0a-447c-be46-99c249a16b90%
>> 40googlegroups.com
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> 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%3D0gLvmTds6dDKU%3D%3DK%3DAHybyG2hcuJPa-
> 0A46cDmY2sPXO1jg%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAOFgAM%3Dgguwq1qCrxMf8hzir0RXVarv1oD00FQDR5%2BgT3E3v5Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] button_to question

2016-11-15 Thread Colin Law
On 15 November 2016 at 16:55, Joe Guerra  wrote:

> ok, it's looking for a view at that route (or path), but my method says to
> render a partial file (modal dialog page).
>
> Hmmm, did I miss something?
>

Without more information it is impossible to say.

Colin


>
> On Tuesday, November 15, 2016 at 2:35:31 AM UTC-5, Colin Law wrote:
>>
>> On 14 November 2016 at 23:17, Joe Guerra  wrote:
>>
>>> Hi,
>>>
>>> I'm trying to run a method in one of my controllers using a button_to
>>> command.  How is this accomplished?
>>>
>>> So far, I've got <%= button_to "Add to Cart", action: "add_to_cart" %>
>>> in my products page
>>>
>>> I defined a add_to_cart in my product controller, and created a route
>>> for it.
>>>
>>> Am I on the right track?  Will it execute code in that method in that
>>> controller?
>>>
>>
>> Try it and see, that would be a lot quicker than asking here. If it
>> doesn't then look in log/development.log and/or the server terminal window
>> to get a clue as to why not.  When setting the route don't forget that
>> button_to will use POST.
>>
>> Colin
>>
>>
>>>
>>> Thanks,
>>> Joe
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ruby on Rails: Talk" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to rubyonrails-ta...@googlegroups.com.
>>> To post to this group, send email to rubyonra...@googlegroups.com.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/rubyonrails-talk/28e7bbb6-bd2c-4661-a5e3-8663135aef27%
>>> 40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> 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/25d8e39f-de0a-447c-be46-
> 99c249a16b90%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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%3D0gLvmTds6dDKU%3D%3DK%3DAHybyG2hcuJPa-0A46cDmY2sPXO1jg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] button_to question

2016-11-15 Thread Joe Guerra
ok, it's looking for a view at that route (or path), but my method says to 
render a partial file (modal dialog page).

Hmmm, did I miss something?

On Tuesday, November 15, 2016 at 2:35:31 AM UTC-5, Colin Law wrote:
>
> On 14 November 2016 at 23:17, Joe Guerra  > wrote:
>
>> Hi,
>>
>> I'm trying to run a method in one of my controllers using a button_to 
>> command.  How is this accomplished?
>>
>> So far, I've got <%= button_to "Add to Cart", action: "add_to_cart" %> in 
>> my products page
>>
>> I defined a add_to_cart in my product controller, and created a route for 
>> it.  
>>
>> Am I on the right track?  Will it execute code in that method in that 
>> controller?
>>
>
> Try it and see, that would be a lot quicker than asking here. If it 
> doesn't then look in log/development.log and/or the server terminal window 
> to get a clue as to why not.  When setting the route don't forget that 
> button_to will use POST.
>
> Colin
>  
>
>>
>> Thanks,
>> Joe
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ruby on Rails: Talk" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to rubyonrails-ta...@googlegroups.com .
>> To post to this group, send email to rubyonra...@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/rubyonrails-talk/28e7bbb6-bd2c-4661-a5e3-8663135aef27%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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/25d8e39f-de0a-447c-be46-99c249a16b90%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Very strange behavior of rails assets

2016-11-15 Thread Scott Jacobsen
Be sure you are running in production mode by setting the RAILS_ENV
environment variable to production.

On Nov 15, 2016 5:35 AM, "Karthikeyan A K" <77mi...@gmail.com> wrote:

> Hello People,
>
> I have just deployed an app on Ubuntu 14.04, Rails 5.0.x, Puma, Nginx.
> Even though I have precompiled assets I am getting the following output:
>
>  data-turbolinks-track="reload" /> data-turbolinks-track="reload">
>
> And ofcourse no javascript and css is not loading and returning 404.
>
> In the very same server I have Rails 4.2.x app which works perfectly.
> Could any one guess what could have gone wrong?
>
> --
> Karthikeyan A K
> http://thepro.in/profiles/karthikeyan-a-k-1
>
> --
> 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/CAJR%2B9kbA4d-ibE-ARDy2JQmjHC3OT7C2pf5vpB%
> 2Bj26Tnjss2LA%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAK5aKabczQFdarca%3Ds8T_wsEQXfcmJeKtSt9%3DBmwE0EgQqebhQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Very strange behavior of rails assets

2016-11-15 Thread Karthikeyan A K
Hello People,

I have just deployed an app on Ubuntu 14.04, Rails 5.0.x, Puma, Nginx. Even
though I have precompiled assets I am getting the following output:



And ofcourse no javascript and css is not loading and returning 404.

In the very same server I have Rails 4.2.x app which works perfectly. Could
any one guess what could have gone wrong?

-- 
Karthikeyan A K
http://thepro.in/profiles/karthikeyan-a-k-1

-- 
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/CAJR%2B9kbA4d-ibE-ARDy2JQmjHC3OT7C2pf5vpB%2Bj26Tnjss2LA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.