Ruby on Rails Wednesday, May 31, 2017

Hassan is correctly encouraging you towards the higher-level abstractions, like a Gem specifically written for this purpose.


If you really want to know how to make outgoing http requests, the answer is the Net::HTTP Ruby library, which is documented here:


But as Hassan said if there's a higher level abstraction, like a Gem, prefer that to writing your own low-level code.

But as a ruby developer the Net::HTTP Ruby library is at the very least something you should learn about and play around with, even if you don't actually need it for this immediate purpose.
-Jason



On May 31, 2017, at 1:39 PM, Joe Guerra <JGuerra@jginfosys.com> wrote:

Ok, I'll try the gem.

How about passing the parameters in the url?  and opening up the canada post site with that?

Thanks,
Joe

On Wednesday, May 31, 2017 at 1:36:20 PM UTC-4, Hassan Schroeder wrote:
On Wed, May 31, 2017 at 10:27 AM, Joe Guerra <JGu...@jginfosys.com> wrote:
> Hmm, which gem would allow you to perform http requests within Rails?  I
> would like to send a request to the canadapost website and pass it some
> parameters and return a shipping total.
>
> I do believe there is a canadapost gem, but I'm not sure how upto date it
> is.

Searching for `ruby gem canada post` turns up more than one -- why
don't you just try them and see which you prefer?

Similarly `ruby gem http` will show you some possibilities if you want
to roll your own solution. See also:
https://ruby-doc.org/stdlib-2.4.1/libdoc/net/http/rdoc/index.html

HTH!
--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
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+unsubscribe@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/80f27a88-f7ca-4bc8-a66c-380da41a4ccf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

If you'd like to reply by encrypted email you can find my public key on jasonfleetwoodboldt.com (more about setting GPG: https://gpgtools.org

Ruby on Rails

On Wed, May 31, 2017 at 10:39 AM, Joe Guerra <JGuerra@jginfosys.com> wrote:

> How about passing the parameters in the url? and opening up the canada post
> site with that?

You can certainly do that, if one of the gems doesn't meet your needs.

Have you read the Canada Post API docs?

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
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+unsubscribe@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/CACmC4yAt-7xEk%2BhLtWLxMcmhyaknuzP9hrucUPCZz2K0%3DyB1JQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Ok, I'll try the gem.

How about passing the parameters in the url?  and opening up the canada post site with that?

Thanks,
Joe

On Wednesday, May 31, 2017 at 1:36:20 PM UTC-4, Hassan Schroeder wrote:
On Wed, May 31, 2017 at 10:27 AM, Joe Guerra <JGu...@jginfosys.com> wrote:
> Hmm, which gem would allow you to perform http requests within Rails?  I
> would like to send a request to the canadapost website and pass it some
> parameters and return a shipping total.
>
> I do believe there is a canadapost gem, but I'm not sure how upto date it
> is.

Searching for `ruby gem canada post` turns up more than one -- why
don't you just try them and see which you prefer?

Similarly `ruby gem http` will show you some possibilities if you want
to roll your own solution. See also:
https://ruby-doc.org/stdlib-2.4.1/libdoc/net/http/rdoc/index.html

HTH!
--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
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+unsubscribe@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/80f27a88-f7ca-4bc8-a66c-380da41a4ccf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Wed, May 31, 2017 at 10:27 AM, Joe Guerra <JGuerra@jginfosys.com> wrote:
> Hmm, which gem would allow you to perform http requests within Rails? I
> would like to send a request to the canadapost website and pass it some
> parameters and return a shipping total.
>
> I do believe there is a canadapost gem, but I'm not sure how upto date it
> is.

Searching for `ruby gem canada post` turns up more than one -- why
don't you just try them and see which you prefer?

Similarly `ruby gem http` will show you some possibilities if you want
to roll your own solution. See also:
https://ruby-doc.org/stdlib-2.4.1/libdoc/net/http/rdoc/index.html

HTH!
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
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+unsubscribe@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/CACmC4yAujFWb8sdRi0tcPfrtwCW6NrkFZ6rKCKb20AteY1u_7Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hmm, which gem would allow you to perform http requests within Rails?  I would like to send a request to the canadapost website and pass it some parameters and return a shipping total.

I do believe there is a canadapost gem, but I'm not sure how upto date it is.

I guess the other option is to like add paramters to a url and open that page on a new tab?

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-talk+unsubscribe@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/242b9e4c-637e-40ca-9021-a831325494b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

I suspect the issue is that you've referred directly to a primary key called `projects.id` in your SQL, but (from the `belongs_to` call) we can see that column is actually called `baseline_id`.

Have you tried changing 'projects.id IN (?)' to 'projects.baseline_id IN (?)' in your initial query? That might sort it.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@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/2265d327-8a03-4eca-bd61-91da536747f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

First of all, thank you for your quick reply!!!

The relation is a bit complex:

in the investment's model there is this relation:

belongs_to :project, :class_name => "Baseline", :foreign_key => :baseline_id
this is the relation between investment and project

Em quarta-feira, 31 de maio de 2017 11:47:19 UTC+1, Marco Antonio Almeida escreveu:
Hi João,

The problem is that you don't have a field called 'projects.id' in the 'investments' table. Does your investment model belongs to one project? Then you would do 

Investment.revenues
  .where(project_id: @projects.map { |p| p.id })
  .includes(:expenses, baseline: [:project, :coordinator])

However, I need to have more information on the database schema to have a better insight. It could also be that you have a many to many relationship between projects and investments and you would need other setup for that, but it depends on how the fields are setup.

Kind regards,
/ Marco

On Wed, May 31, 2017 at 12:16 PM João Bordalo <bordalo...@gmail.com> wrote:
Hi, there.

I'm trying to solve a problem that previously worked on rails 3.2 and isn't in rails 4.2:

The query is the following: 
Investment.revenues
            .where('projects.id IN (?)', @projects.map { |p| p.id })
            .includes(:expenses, :baseline => [:project, :coordinator]). 

The error is this: 
SQLite3::SQLException: no such column: projects.id: SELECT "investments".* FROM "investments" INNER JOIN "classifications" ON "classifications"."id" = "investments"."classification_id" INNER JOIN "baselines" ON "baselines"."id" = "investments"."baseline_id" WHERE "classifications"."pl_line_mask" IN (0, 1, 8, 10, 11) AND "baselines"."type_mask" = ? AND (projects.id IN (169,177,286,292,301,360,361,365,422,423,424,438,443,452,472,520,525,566,575,583,592,604,605,606,607,608,609,610,611,612,613,614,615,616,617,618,619,620,622))

I believe this error is related to how the in operator is been used. I can't find documentation related to this operator.

How can I solve this situation?


Thank you in advance,
João Bordalo

--
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/51bb61be-7eda-4548-9d3c-21c0652b2a61%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+unsubscribe@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/30fe6f15-2d39-41a3-8c15-ae1f8362deb5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

What is the relationship between a club and a press release? Does a club have many press releases? Start with the real-world relationship, then add that relationship to your Rails models. The answer will suggest itself.

Walter

> On May 30, 2017, at 10:57 PM, fugee ohu <fugee279@gmail.com> wrote:
>
> I'm creating a new PressRelease the PressRelease model has no club_id column it has columns like venue, venue_city, venue_state, etc. I wanna add a collection_select to the form to get a club_id into the params from the Club model How should my collection_select be constructed I have something like <%= f.collection_select(:club_id, Club.all, :id, :club, prompt: true) %> but this causes an undefined method 'club_id' error
>
>
> --
> 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+unsubscribe@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/7f636bca-f73d-477f-8687-ae91019a2547%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+unsubscribe@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/BE359B17-9275-4528-A8DD-5BF9E4218339%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hi João,

The problem is that you don't have a field called 'projects.id' in the 'investments' table. Does your investment model belongs to one project? Then you would do 

Investment.revenues
  .where(project_id: @projects.map { |p| p.id })
  .includes(:expenses, baseline: [:project, :coordinator])

However, I need to have more information on the database schema to have a better insight. It could also be that you have a many to many relationship between projects and investments and you would need other setup for that, but it depends on how the fields are setup.

Kind regards,
/ Marco

On Wed, May 31, 2017 at 12:16 PM João Bordalo <bordalo.joao94@gmail.com> wrote:
Hi, there.

I'm trying to solve a problem that previously worked on rails 3.2 and isn't in rails 4.2:

The query is the following: 
Investment.revenues
            .where('projects.id IN (?)', @projects.map { |p| p.id })
            .includes(:expenses, :baseline => [:project, :coordinator]). 

The error is this: 
SQLite3::SQLException: no such column: projects.id: SELECT "investments".* FROM "investments" INNER JOIN "classifications" ON "classifications"."id" = "investments"."classification_id" INNER JOIN "baselines" ON "baselines"."id" = "investments"."baseline_id" WHERE "classifications"."pl_line_mask" IN (0, 1, 8, 10, 11) AND "baselines"."type_mask" = ? AND (projects.id IN (169,177,286,292,301,360,361,365,422,423,424,438,443,452,472,520,525,566,575,583,592,604,605,606,607,608,609,610,611,612,613,614,615,616,617,618,619,620,622))

I believe this error is related to how the in operator is been used. I can't find documentation related to this operator.

How can I solve this situation?


Thank you in advance,
João Bordalo

--
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+unsubscribe@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/51bb61be-7eda-4548-9d3c-21c0652b2a61%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+unsubscribe@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/CACMkcE5Q0M9gsBq%3DAsMhcrUsQtLg9FpSCt5Lm21Fqik2%3DqFRrQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hi, there.

I'm trying to solve a problem that previously worked on rails 3.2 and isn't in rails 4.2:

The query is the following: 
Investment.revenues
            .where('projects.id IN (?)', @projects.map { |p| p.id })
            .includes(:expenses, :baseline => [:project, :coordinator]). 

The error is this: 
SQLite3::SQLException: no such column: projects.id: SELECT "investments".* FROM "investments" INNER JOIN "classifications" ON "classifications"."id" = "investments"."classification_id" INNER JOIN "baselines" ON "baselines"."id" = "investments"."baseline_id" WHERE "classifications"."pl_line_mask" IN (0, 1, 8, 10, 11) AND "baselines"."type_mask" = ? AND (projects.id IN (169,177,286,292,301,360,361,365,422,423,424,438,443,452,472,520,525,566,575,583,592,604,605,606,607,608,609,610,611,612,613,614,615,616,617,618,619,620,622))

I believe this error is related to how the in operator is been used. I can't find documentation related to this operator.

How can I solve this situation?


Thank you in advance,
João Bordalo

--
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+unsubscribe@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/51bb61be-7eda-4548-9d3c-21c0652b2a61%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Tuesday, May 30, 2017

I'm creating a new PressRelease  the PressRelease model has no club_id column it has columns like venue, venue_city, venue_state, etc. I wanna add a collection_select to the form to get a club_id into the params from the Club model How should my collection_select be constructed I have something like  <%= f.collection_select(:club_id, Club.all, :id, :club, prompt: true) %> but this causes an undefined method 'club_id' error

--
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+unsubscribe@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/7f636bca-f73d-477f-8687-ae91019a2547%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

lol, downtown where?

On Tuesday, May 30, 2017 at 2:21:48 PM UTC-4, Lisa Thompson wrote:

Company

Fast-growing software company located downtown.

 

Perks

Doubled in size in the past 6 months

Huge career growth opportunities

Talented team

 

Job – Ruby on Rails Developer (javascript, PostgreSQL)

·       We are seeking a Rails Developer to work on our core platform.

·       4+ years' experience developing enterprise Rails web applications

·       4+ years' experience javascript development (javascript, html5, css3                                                                                                        

·       PostgreSQL, AWS, Elastic Search, iOS, XCode, Swift

·       Ember.js experience is a BONUS!

--
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+unsubscribe@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/5bdae204-cb7b-49a5-92d1-88f282cce006%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

We are searching globally for the very best Ruby / Rails people to come and head up a new team here in Bristol.  My client is one of the leading employers in Japan and this is a genuinely exciting role for the right person. Salaries offered will be competitive and there is huge scope for progression.  They have taken a new office in the centre of Bristol (voted best place to live in the UK by the Telegraph!), and so far only have a few seats taken in a huge space!   If you like to use modern architecture to create truly modern apps please get in touch!  

--
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+unsubscribe@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/228015a1-d351-4813-9d1e-6fae8f7557a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Company

Fast-growing software company located downtown.

 

Perks

Doubled in size in the past 6 months

Huge career growth opportunities

Talented team

 

Job – Ruby on Rails Developer (javascript, PostgreSQL)

·       We are seeking a Rails Developer to work on our core platform.

·       4+ years' experience developing enterprise Rails web applications

·       4+ years' experience javascript development (javascript, html5, css3                                                                                                        

·       PostgreSQL, AWS, Elastic Search, iOS, XCode, Swift

·       Ember.js experience is a BONUS!

--
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+unsubscribe@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/a83d7377-49dd-43c2-9f6f-5d551d02ef11%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hi Guys,

I am a Perl developer and new to Ruby on Rails . Recently, I have setup a new rails application ( Ruby 2.4.0 and Rails 5.0.2 ) . When I launch the application after starting rails server , it generates an error "ORA-06413: Connection not open" . I am using ruby-oci8 (2.2.3) and activerecord-oracle_enhanced-adapter (1.7.9) and oracle client ( 10.1.0 ) . I have also set ORACLE_HOME , LD_LIBRARY_PATH , TNS_ADMIN environment variables in .bash_profile . I am getting below error  ; 


ORA-06413: Connection not open.

Rails.root: /home/akhand/work_space/test_app Application Trace | Framework Trace | Full Trace

oci8.c:654:in oci8lib_240.so ruby-oci8 (2.2.3) lib/oci8/oci8.rb:142:in initialize' activerecord-oracle_enhanced-adapter (1.7.9) lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:346:innew' activerecord-oracle_enhanced-adapter (1.7.9) lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:346:in new_connection' activerecord-oracle_enhanced-adapter (1.7.9) lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:405:ininitialize' activerecord-oracle_enhanced-adapter (1.7.9) lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:24:in new' activerecord-oracle_enhanced-adapter (1.7.9) lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:24:ininitialize' activerecord-oracle_enhanced-adapter (1.7.9) lib/active_record/connection_adapters/oracle_enhanced/connection.rb:8:in new' activerecord-oracle_enhanced-adapter (1.7.9) lib/active_record/connection_adapters/oracle_enhanced/connection.rb:8:increate' activerecord-oracle_enhanced-adapter (1.7.9) lib/active_record/connection_adapters/oracle_enhanced_adapter.rb:169:in oracle_enhanced_connection' activerecord (5.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:729:innew_connection' activerecord (5.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:773:in checkout_new_connection' activerecord (5.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:752:intry_to_checkout_new_connection'


I have configured database.yml and tnsnames.ora correctly but not sure why I am getting this error . Is Oracle 10 is the reason for this error ? Please suggest . FYI , I am able to connect and fetch result of SQL queries manually through the terminal using below command ;


ruby -r oci8 -e "OCI8.new('user',  'password', '//databasehost:1521/testdb').exec('SELECT * FROM application_account') do |r| puts r.join(' | '); end"


But not sure why it's creating problem at rails app level . I tried all the solutions that I found on google but none of them worked . 



Regards,

Akhand 

--
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+unsubscribe@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/9fcd12ab-39dd-40d4-9df8-51c023f50e7e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hi Everyone!

if everyone is interest in a position of Ruby developer in italy, send an email to curriculum@group4business.com

Best regards
Fabiano

--
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+unsubscribe@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/8d8e16a5-5113-458a-9bfb-3332047cb59e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Monday, May 29, 2017

ok, the context is I have this table to update users with small notifications messages. 

Rails scaffold generated a userid and msg form.   Now, when I need to send a user a message I look them up in the table, grab their id and then put the id in the field along with a message.

Thanks,
Joe

On Mon, May 29, 2017 at 1:55 PM, Walter Lee Davis <waltd@wdstudio.com> wrote:


> On May 29, 2017, at 1:34 PM, Joe Guerra <jguerra@jginfosys.com> wrote:
>
> Hi, I have this notifications table which basically has a userid and a msg (notification).
>
> What should I do with the userid?  I would like to look up the user by name and stick the id in the table.
>
> Is that normally what you'd do in this case?  A dropdown list would be too large.
>
> Thanks,
> Joe

When (how often) would you want to get the user's name? That's the question I would ask before deciding whether to denormalize this or not.

If you're just doing a listing on a table, you could do Notification.includes(:user).where ... and that would lazy-load the users for you, so you could get the user's name without an N+1 lookup. If you are showing the user all of their notifications, then you would be doing something like current_user.notifications ... so you would have the user already that way.

The answer to your question depends on the context.

Walter

--
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+unsubscribe@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/C910C1AA-AECA-4A2E-844A-C116B88A8796%40wdstudio.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+unsubscribe@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/CAOFgAMmUzgxCuHFoOVk%3DCxDn6%3D63mjoXwEAa_rfPrCS9oCBxaQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

> On May 29, 2017, at 1:34 PM, Joe Guerra <jguerra@jginfosys.com> wrote:
>
> Hi, I have this notifications table which basically has a userid and a msg (notification).
>
> What should I do with the userid? I would like to look up the user by name and stick the id in the table.
>
> Is that normally what you'd do in this case? A dropdown list would be too large.
>
> Thanks,
> Joe

When (how often) would you want to get the user's name? That's the question I would ask before deciding whether to denormalize this or not.

If you're just doing a listing on a table, you could do Notification.includes(:user).where ... and that would lazy-load the users for you, so you could get the user's name without an N+1 lookup. If you are showing the user all of their notifications, then you would be doing something like current_user.notifications ... so you would have the user already that way.

The answer to your question depends on the context.

Walter

--
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+unsubscribe@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/C910C1AA-AECA-4A2E-844A-C116B88A8796%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hi, I have this notifications table which basically has a userid and a msg (notification).

What should I do with the userid?  I would like to look up the user by name and stick the id in the table.  

Is that normally what you'd do in this case?  A dropdown list would be too large.

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-talk+unsubscribe@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/f2e33535-119a-496f-ada2-7502d9826833%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On 29 May 2017 at 14:32, Walter Lee Davis <waltd@wdstudio.com> wrote:
>
>> On May 29, 2017, at 3:59 AM, Colin Law <clanlaw@gmail.com> wrote:
>>
>> On 28 May 2017 at 23:26, fugee ohu <fugee279@gmail.com> wrote:
>>>
>>>
>>> On Sunday, May 28, 2017 at 4:58:13 PM UTC-4, Colin Law wrote:
>>>>
>>>> On 28 May 2017 at 21:17, fugee ohu <fuge...@gmail.com> wrote:
>>>>> I wanna add a dropdown menu to my index view for the index action of my
>>>>> artists_controller Trying to use collection_select but it responds
>>>>> undefined
>>>>> method `collection_select' for nil:NilClass The idea is to list artists
>>>>> by
>>>>> genre
>>>>>
>>>>> <div class="field"> <%= f.collection_select( :artist, :genre, Genre.all,
>>>>> :id, :name) %> </div>
>>>>
>>>> How are you setting f?
>>>>
>>>> Colin
>>>
>>>
>>> <%= form_tag(artists_path) do |f| %>
>>
>> form_tag must be used inside a form, it does not create a form
>>
>> Colin
>
>
> No, form_tag creates a form tag, unbound to any model object.

You are right of course. I am getting old :(

Colin

>
> http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-form_tag
>
> I think where the OP may be getting off track is that the form created by form_tag doesn't have a bound object, so saying f.collection_select is sort of meaningless. That syntax is used when you bind the form to an object, such as when you use form_for(@foo). You can use collection_select with or without an object, in the latter form, you have to provide the object as the first argument, but when you use the f.collection_select syntax, that first argument becomes the second argument, and the first argument is picked up from the f reference.
>
> I think, ultimately, that's what's going on here -- the entire set of arguments to the helper are being shifted left one step, and the meaningless reference to the form builder (without bound object) is being passed in to the tag helper.
>
> Walter
>
> --
> 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+unsubscribe@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/2FCF702E-E978-429C-999C-34B20FD514AC%40wdstudio.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+unsubscribe@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%3D0gLsYoU5KVUDfFWZRjhO8FxThkUe4gL0TSO9cJYk7Efd2%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

> On May 29, 2017, at 3:59 AM, Colin Law <clanlaw@gmail.com> wrote:
>
> On 28 May 2017 at 23:26, fugee ohu <fugee279@gmail.com> wrote:
>>
>>
>> On Sunday, May 28, 2017 at 4:58:13 PM UTC-4, Colin Law wrote:
>>>
>>> On 28 May 2017 at 21:17, fugee ohu <fuge...@gmail.com> wrote:
>>>> I wanna add a dropdown menu to my index view for the index action of my
>>>> artists_controller Trying to use collection_select but it responds
>>>> undefined
>>>> method `collection_select' for nil:NilClass The idea is to list artists
>>>> by
>>>> genre
>>>>
>>>> <div class="field"> <%= f.collection_select( :artist, :genre, Genre.all,
>>>> :id, :name) %> </div>
>>>
>>> How are you setting f?
>>>
>>> Colin
>>
>>
>> <%= form_tag(artists_path) do |f| %>
>
> form_tag must be used inside a form, it does not create a form
>
> Colin


No, form_tag creates a form tag, unbound to any model object.

http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-form_tag

I think where the OP may be getting off track is that the form created by form_tag doesn't have a bound object, so saying f.collection_select is sort of meaningless. That syntax is used when you bind the form to an object, such as when you use form_for(@foo). You can use collection_select with or without an object, in the latter form, you have to provide the object as the first argument, but when you use the f.collection_select syntax, that first argument becomes the second argument, and the first argument is picked up from the f reference.

I think, ultimately, that's what's going on here -- the entire set of arguments to the helper are being shifted left one step, and the meaningless reference to the form builder (without bound object) is being passed in to the tag helper.

Walter

--
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+unsubscribe@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/2FCF702E-E978-429C-999C-34B20FD514AC%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Good morning,


I haven't done an autocomplete with a nested form in quite some time and can't find any good references.  I posted to SO here: https://stackoverflow.com/questions/44232005/rails-5-nested-form-find-or-create

Basically I have two models Run and Patient.  Run belongs_to patient and Patient has_many runs.  Run accepts_nested_attributes for patient.

What I want to do is when creating a new run, have a select box that let's me type out of the name of the patient, if they exist and it's the right patient, use that ID in the form.  If the patient does not exist, then create the nested association patient record.  I'm hoping to do this with autocomplete too.

Any guidance is greatly appreciated.

Thanks!

Ruby on Rails

On 28 May 2017 at 23:26, fugee ohu <fugee279@gmail.com> wrote:
>
>
> On Sunday, May 28, 2017 at 4:58:13 PM UTC-4, Colin Law wrote:
>>
>> On 28 May 2017 at 21:17, fugee ohu <fuge...@gmail.com> wrote:
>> > I wanna add a dropdown menu to my index view for the index action of my
>> > artists_controller Trying to use collection_select but it responds
>> > undefined
>> > method `collection_select' for nil:NilClass The idea is to list artists
>> > by
>> > genre
>> >
>> > <div class="field"> <%= f.collection_select( :artist, :genre, Genre.all,
>> > :id, :name) %> </div>
>>
>> How are you setting f?
>>
>> Colin
>
>
> <%= form_tag(artists_path) do |f| %>

form_tag must be used inside a form, it does not create a form

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+unsubscribe@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/1340f13b-8e7c-4e81-a63d-e28833acf816%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+unsubscribe@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%3D0gLs6LG9Ranzd_8H3o%2BcMSN6Td7%3Dqqxvj9UEQ0qqbNLQO9A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Sunday, May 28, 2017



On Sunday, May 28, 2017 at 4:58:13 PM UTC-4, Colin Law wrote:
On 28 May 2017 at 21:17, fugee ohu <fuge...@gmail.com> wrote:
> I wanna add a dropdown menu to my index view for the index action of my
> artists_controller Trying to use collection_select but it responds undefined
> method `collection_select' for nil:NilClass The idea is to list artists by
> genre
>
> <div class="field"> <%= f.collection_select( :artist, :genre, Genre.all,
> :id, :name) %> </div>

How are you setting f?

Colin

<%= form_tag(artists_path) do |f| %>
 

--
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+unsubscribe@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/1340f13b-8e7c-4e81-a63d-e28833acf816%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On 28 May 2017 at 21:17, fugee ohu <fugee279@gmail.com> wrote:
> I wanna add a dropdown menu to my index view for the index action of my
> artists_controller Trying to use collection_select but it responds undefined
> method `collection_select' for nil:NilClass The idea is to list artists by
> genre
>
> <div class="field"> <%= f.collection_select( :artist, :genre, Genre.all,
> :id, :name) %> </div>

How are you setting f?

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+unsubscribe@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%3D0gLtRuu1Nn7SSBss5Jvt%2BLmxMPbYT%3DVFPR0A1-fY27Sa%3DJQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Sunday, May 28, 2017 at 4:28:35 PM UTC-4, Chris Lerum wrote:
try <%= f.collection_select( :artist, :genre_id, Genre.all, :id, :name) %>

On Sunday, May 28, 2017 at 4:17:53 PM UTC-4, fugee ohu wrote:
I wanna add a dropdown menu to my index view for the index action of my artists_controller Trying to use collection_select but it responds undefined method `collection_select' for nil:NilClass The idea is to list artists by genre

<div class="field"> <%= f.collection_select( :artist, :genre, Genre.all, :id, :name) %> </div>


gets me the same error, the  object is plural @artists, there's no form_for @artists instead i'm using <%= form_tag(artists_path) do |f| %>

--
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+unsubscribe@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/86014fc8-fffa-43a4-926a-ab8aa5ae73b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

try <%= f.collection_select( :artist, :genre_id, Genre.all, :id, :name) %>

On Sunday, May 28, 2017 at 4:17:53 PM UTC-4, fugee ohu wrote:
I wanna add a dropdown menu to my index view for the index action of my artists_controller Trying to use collection_select but it responds undefined method `collection_select' for nil:NilClass The idea is to list artists by genre

<div class="field"> <%= f.collection_select( :artist, :genre, Genre.all, :id, :name) %> </div>

--
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+unsubscribe@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/47a9dff5-9513-40d7-ada5-f315ce4fdfd0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

I wanna add a dropdown menu to my index view for the index action of my artists_controller Trying to use collection_select but it responds undefined method `collection_select' for nil:NilClass The idea is to list artists by genre

<div class="field"> <%= f.collection_select( :artist, :genre, Genre.all, :id, :name) %> </div>

--
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+unsubscribe@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/8cb2b9d3-853f-4fec-87a2-e15fed097c68%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Saturday, May 27, 2017

oh, I don't know what happened.  But  I pushed it up to github again and deployed it on heroku and it works . now.
Must have been a few files that were not included in the original push.

Thanks,
Joe

On Saturday, May 27, 2017 at 11:03:40 AM UTC-4, nynhex wrote:
Good call on this one, request and response are almost reserved naming conventions in rails.

> On May 27, 2017, at 9:32 AM, Hassan Schroeder <hassan.s...@gmail.com> wrote:
>
> On Sat, May 27, 2017 at 6:15 AM, Joe Guerra <JGu...@jginfosys.com> wrote:
>> Hi, I'm not sure why my app on heroku is crashing.
>> I've added a requests controller, and everything works locally using sqlite.
>
> "works" in the sense that you have tests for this part of your code?
>
> That aside, having a "requests" controller sounds like a phenomenally
> bad idea -- "request" and "response" have very specific meanings in
> any web application, and in the case of Rails request() is an instance
> method of ActionController::Base.
>
> I would strongly recommend changing the name of that controller :-)
>
> --
> Hassan Schroeder ------------------------ hassan.s...@gmail.com
> twitter: @hassan
> Consulting Availability : Silicon Valley or remote
>
> --
> 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/CACmC4yDAbayWntKqCuUES1M5bAorxiZkfq5h3Syn%3D30%2B76k07Q%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+unsubscribe@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/1842ec4d-8d64-4cdc-9fa1-f22c4d131da4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Good call on this one, request and response are almost reserved naming conventions in rails.

> On May 27, 2017, at 9:32 AM, Hassan Schroeder <hassan.schroeder@gmail.com> wrote:
>
> On Sat, May 27, 2017 at 6:15 AM, Joe Guerra <JGuerra@jginfosys.com> wrote:
>> Hi, I'm not sure why my app on heroku is crashing.
>> I've added a requests controller, and everything works locally using sqlite.
>
> "works" in the sense that you have tests for this part of your code?
>
> That aside, having a "requests" controller sounds like a phenomenally
> bad idea -- "request" and "response" have very specific meanings in
> any web application, and in the case of Rails request() is an instance
> method of ActionController::Base.
>
> I would strongly recommend changing the name of that controller :-)
>
> --
> Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
> twitter: @hassan
> Consulting Availability : Silicon Valley or remote
>
> --
> 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+unsubscribe@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/CACmC4yDAbayWntKqCuUES1M5bAorxiZkfq5h3Syn%3D30%2B76k07Q%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+unsubscribe@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/A0F45EB2-F86C-4B8E-BFB3-5240EE464B3A%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Sat, May 27, 2017 at 6:15 AM, Joe Guerra <JGuerra@jginfosys.com> wrote:
> Hi, I'm not sure why my app on heroku is crashing.
> I've added a requests controller, and everything works locally using sqlite.

"works" in the sense that you have tests for this part of your code?

That aside, having a "requests" controller sounds like a phenomenally
bad idea -- "request" and "response" have very specific meanings in
any web application, and in the case of Rails request() is an instance
method of ActionController::Base.

I would strongly recommend changing the name of that controller :-)

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
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+unsubscribe@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/CACmC4yDAbayWntKqCuUES1M5bAorxiZkfq5h3Syn%3D30%2B76k07Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.