Ruby on Rails Friday, March 30, 2018

Section of html code

<div id="dealersCards">
<span id = "D0"></span>
<span id = "D1"></span>
<span id = "D2"></span>
<span id = "D3"></span>
<span id = "D4"></span>
<span id = "D5"></span>
<span id = "D6"></span>
<span id = "D7"></span>
</div>

Corresponding javasript code

function displayPlayerOneInitialCards()
{
length = dealerCards.length;
for( dealerCount = 0; dealerCount < length; dealerCount++) 
newCard = dealerCards[dealerCount]
if(dealerCount == 0)
{
var cardToDisplay = newCard.cardFaceDown;
}
if(dealerCount == 1)
{
var cardToDisplay = newCard.cardToDisplay;
}
dealerIdName = 'D';
dealerIdName   = dealerIdName  + dealerCount.toString();
fileNameCard= '<img  width="80" height="128" src="images/'+(cardToDisplay.trim())+'" alt="Card"/>';
document.getElementById(dealerIdName).innerHTML = fileNameCard;
}
}

Images are in app/assets

Error message eg 

No route matches [GET] "/game/BlackJack/images/H3.gif"


This works in the broswer but wanting ity to work with Rails

Any suggestion please.

Cheers Dave



--
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/e145956e-37ae-4e70-a91b-2bd7e1ab158f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hi all --

Since 2009, we've been conducting surveys and sharing all the results (in the spirit of open source!) with the community every 2-3 years. Our current survey has been open all month and closes tomorrow. We're aiming to share the results in the next few weeks -- if you have not taken it, yet, please do take a few minutes and hop over to:

  • http://rails-hosting.com/
Thanks in advance!

Cheers,
Robby


Robby Russell 
VP Engineering, Principal  
Planet Argon, LLC
+1 503 847 9214 x701
https://www.planetargon.com/robby

--
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/09b47f83-24fa-413c-9b6f-3e695d84f9c5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Javascript include tags not causing get requests, what could be the cause i've listed them as requires in application.js //= require somefile.js i've listed them in intitializers/assets.rb The javascript in the layout wrapper is working 

--
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/11901fab-7464-4b3b-99a6-decd45ea78aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Thursday, March 29, 2018

Thanks Hassan, it works now.

On Thu, Mar 29, 2018 at 2:42 PM, Hassan Schroeder <hassan.schroeder@gmail.com> wrote:
On Thu, Mar 29, 2018 at 8:16 AM, Majid Lotfi <akramakom@gmail.com> wrote:

> in the search area I have two date pickers from to, when you pick the dates
> they come like : 2018-03-27 , my question, how to convert :
>
> 2018-03-27 to 2018 Mar 27

Have you looked at the Date section of the (stdlib) docs?

One approach:

2.5.1 (main):0 > Date.parse("2018-03-27").strftime("%Y %b %d")
=> "2018 Mar 27"

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/CACmC4yAYVpynDWAK2NMYBGf%3DcWn8ZnX56H0mTweZ0ZCAAo63fQ%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/CAK%2Bp6EzZpJj5yh7cCiAWwG4Fno6jbZpEYX_WSYEhMfoHLw%3DsiQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hi everyone,

I am happy to announce that Rails 5.0.7 and 5.1.6 have been released.


## CHANGES since 5.0.6

To view the changes for each gem, please read the changelogs on GitHub:
 
* [Action Cable CHANGELOG](https://github.com/rails/rails/blob/v5.0.7/actioncable/CHANGELOG.md)  
* [Action Mailer CHANGELOG](https://github.com/rails/rails/blob/v5.0.7/actionmailer/CHANGELOG.md)  
* [Action Pack CHANGELOG](https://github.com/rails/rails/blob/v5.0.7/actionpack/CHANGELOG.md)  
* [Action View CHANGELOG](https://github.com/rails/rails/blob/v5.0.7/actionview/CHANGELOG.md)  
* [Active Job CHANGELOG](https://github.com/rails/rails/blob/v5.0.7/activejob/CHANGELOG.md)  
* [Active Model CHANGELOG](https://github.com/rails/rails/blob/v5.0.7/activemodel/CHANGELOG.md)  
* [Active Record CHANGELOG](https://github.com/rails/rails/blob/v5.0.7/activerecord/CHANGELOG.md)  
* [Active Support CHANGELOG](https://github.com/rails/rails/blob/v5.0.7/activesupport/CHANGELOG.md)  
* [Railties CHANGELOG](https://github.com/rails/rails/blob/v5.0.7/railties/CHANGELOG.md)  

*Full listing*

To see the full list of changes, [check out all the commits on
GitHub](https://github.com/rails/rails/compare/v5.0.6...v5.0.7).
 
## CHANGES since 5.1.5

To view the changes for each gem, please read the changelogs on GitHub:
 
* [Action Cable CHANGELOG](https://github.com/rails/rails/blob/v5.1.6/actioncable/CHANGELOG.md)  
* [Action Mailer CHANGELOG](https://github.com/rails/rails/blob/v5.1.6/actionmailer/CHANGELOG.md)  
* [Action Pack CHANGELOG](https://github.com/rails/rails/blob/v5.1.6/actionpack/CHANGELOG.md)  
* [Action View CHANGELOG](https://github.com/rails/rails/blob/v5.1.6/actionview/CHANGELOG.md)  
* [Active Job CHANGELOG](https://github.com/rails/rails/blob/v5.1.6/activejob/CHANGELOG.md)  
* [Active Model CHANGELOG](https://github.com/rails/rails/blob/v5.1.6/activemodel/CHANGELOG.md)  
* [Active Record CHANGELOG](https://github.com/rails/rails/blob/v5.1.6/activerecord/CHANGELOG.md)  
* [Active Support CHANGELOG](https://github.com/rails/rails/blob/v5.1.6/activesupport/CHANGELOG.md)  
* [Railties CHANGELOG](https://github.com/rails/rails/blob/v5.1.6/railties/CHANGELOG.md)  

*Full listing*

To see the full list of changes, [check out all the commits on
GitHub](https://github.com/rails/rails/compare/v5.1.5...v5.1.6).
 
## SHA-256

If you'd like to verify that your gem is the same as the one I've uploaded,
please use these SHA-256 hashes.

Here are the checksums for 5.0.7:

```
$ shasum -a 256 *-5.0.7.gem
c023d1df2fd6f5e1ac042ad6a0338e8a2c4d1404484f8fe77121b81f10b75f2c  actioncable-5.0.7.gem
5f9b12f26ae8906d20b9f4784644853121a3b03f74a396943677fc30f91c2e35  actionmailer-5.0.7.gem
08e0d4582d1b37cc059aca1d19cd271e7bb575265093c4a99cb79d80dcb0d196  actionpack-5.0.7.gem
eb20007cc9ee40ee7a2f96147e9776394f72d59979b23da15f444a9906c17b8b  actionview-5.0.7.gem
e8a15b73302c02352da9463b134daf037841fec7d5d5c2ec97487456f96bb8d5  activejob-5.0.7.gem
fe35b1bbfb140c7416723e3a7d7ef2a78e8921739863d8a917a93131e2b7cc87  activemodel-5.0.7.gem
c6349cd59e29118aaed5d4d2414e87b427affd28925b7fe1559cb45a21152366  activerecord-5.0.7.gem
a595a42311ea13ce994b1feea3325cbbb1ac5c0bf40cd96c89797882121da7fb  activesupport-5.0.7.gem
76815a2a7e99c83b53ea52325c5bbc5ca15e25ecdfb741ea329ca153cf11ff84  rails-5.0.7.gem
e08b95ec3dbb708f9d449a01c083c66d47ddba2f373e4a2fd1bde2c7a92fdb48  railties-5.0.7.gem
```

Here are the checksums for 5.1.6:

```
$ shasum -a 256 *-5.1.6.gem
2e678b45852f242e5897a0d4e43dca1088fb3d5c350592b22768b502a085261f  actioncable-5.1.6.gem
ecbc307e66102b1406fba38f6d7c869fd763cafa98b02fd4f6049fd41d663de9  actionmailer-5.1.6.gem
8dcd333263bdea533de7ac8e087f530f20bde6167c3c02060b82630b90aee26f  actionpack-5.1.6.gem
0181e71b9d307425605c50aa70358148aa0dff270bf2e07dbb87acb3d3a7ddcd  actionview-5.1.6.gem
a291963337402f3dcd5aee1dff3fd980256742bb0cfa06c47315257d11d69a0a  activejob-5.1.6.gem
7e3d2904a524a18c4f710a170243eac706279a36142289431d3c504df665c881  activemodel-5.1.6.gem
1da0546d452cc9b25b900bc2616b57d1e41e24039c33466b46d7add27fdf13c7  activerecord-5.1.6.gem
94d2f2a9fe1a7421165e0014eaa4c8eb2d229f72dc9815cf7c2f0c595f05b521  activesupport-5.1.6.gem
b8301a87151de3feb7cbdf57a66842bb668493f4cec464fd0f67d4c7173b6051  rails-5.1.6.gem
482a97c40ff61f4e8aed5f449a5f54fcb3890ddd53c3a7dc0efd02a9da139e79  railties-5.1.6.gem
```

As always, huge thanks to the many contributors who helped with this release.

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

Ruby on Rails

On Thu, Mar 29, 2018 at 8:16 AM, Majid Lotfi <akramakom@gmail.com> wrote:

> in the search area I have two date pickers from to, when you pick the dates
> they come like : 2018-03-27 , my question, how to convert :
>
> 2018-03-27 to 2018 Mar 27

Have you looked at the Date section of the (stdlib) docs?

One approach:

2.5.1 (main):0 > Date.parse("2018-03-27").strftime("%Y %b %d")
=> "2018 Mar 27"

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

Ruby on Rails

I am doing test using selenium with ruby, I have a web page that has records, one of the columns has dates like 2018 Mar 28 , 

in the search area I have two date pickers from to, when you pick the dates they come like : 2018-03-27 , my question, how to convert :

2018-03-27 to 2018 Mar 27

OR

2018 Mar 27 to  2018-03-27

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 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/8ba88944-4510-4ab3-9e6c-5eda96003199%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Wednesday, March 28, 2018

It's your app. You bring the magic. This could be something stupid-simple, like every 5 seconds a Cron job hits `rails runner -e production 'Auction.handle_finished'`.

No matter what it is, you will have written it. There's nothing magical that happens in Rails that knows when a particular time has passed unless you wake it up and ask it (and write something to handle that case).

Walter

> On Mar 28, 2018, at 2:56 PM, fugee ohu <fugee279@gmail.com> wrote:
>
> What magic is supposed to handle processing at the time an auction ends?
>
> --
> 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/9912afef-13c9-403f-b41d-ff8486de2ad8%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/91340BD3-D72F-4B9D-A01D-E4149729765E%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

What magic is supposed to handle processing at the time an auction ends?

--
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/9912afef-13c9-403f-b41d-ff8486de2ad8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

> On Mar 28, 2018, at 11:11 AM, David McDonald <daveomcd@gmail.com> wrote:
>
> As I'm going through my project I'm looking at places in my application that are causing pages to load longer than perhaps they should. I'm finding some queries that execute for my page navigation that happen each time a page reloads, but their information that is returned doesn't usually change. An example I have would be I display 32 NFL Club logos that serve as links to each clubs page in my navigation. The query looks like this:
>
> SELECT [clubs].* FROM [clubs] WHERE (clubs.is_disabled = 0) ORDER BY [clubs].[city] ASC;
>
>
> Now this code runs in development and it's saying it takes 32.9ms to execute. But to my point these 32 clubs rarely change. Is there a different approach I should be taking to this other than having it run on every page request? Thanks!

You could "memoize" it in a class method, so it runs only once per application start. Take advantage of the fact that Rails is a long-running process.

# in club model

def self.nfl_logos
@nfl_logos ||= where(is_disabled: false).order(city: :asc)
end

Then refer to this as Club.nfl_logos in your controller or view, wherever you build this page element. It will only ever run once (per server instance/thread) and thereafter always return from the cached instance.

Another thing to remember is Turbolinks. You are using it, right? Elements like this that rarely change can be marked out as persistent between reloads, so they will be cached by the browser and never re-requested. Assuming your layout is properly divided into areas that change and areas that do not, this could take care of this problem for you as well.

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/3A531736-9D66-4EBE-9775-577E79EDAD87%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

As I'm going through my project I'm looking at places in my application that are causing pages to load longer than perhaps they should.  I'm finding some queries that execute for my page navigation that happen each time a page reloads, but their information that is returned doesn't usually change.  An example I have would be I display 32 NFL Club logos that serve as links to each clubs page in my navigation.  The query looks like this:

SELECT [clubs].* FROM [clubs] WHERE (clubs.is_disabled = 0)  ORDER BY [clubs].[city] ASC;


Now this code runs in development and it's saying it takes 32.9ms to execute.  But to my point these 32 clubs rarely change.  Is there a different approach I should be taking to this other than having it run on every page request? 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 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/28bf3cfa-33d1-4c90-b1fe-201ae727045d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hi Brian,

Here is an API reference for Rails: http://api.rubyonrails.org/. You need to check on the Rails version that you're using though, so you don't fall into missing or deprecated methods.

There you can find an updated quick reference to the things that you probably dealt with like has_many, belongs_to and so on. But just like our friends here mentioned, and the example you gave us, this quick reference won't help you understand that a parameter :foo_bar_bazes references a class called FooBarBaz. Getting familiar with the Rails way on doing things will definitely help you to go through that.

Kind regards,
// Marco

On Tue, Mar 27, 2018 at 11:48 PM Brian Postow <bpostow@gmail.com> wrote:
by "not references" I meant it's way too verbose for what I need. The rails guides are meant (or appear to be meant) to be read cover to cover. I need something where I can looks a specific thing up.

It's the difference between http://ruby-doc.com/docs/ProgrammingRuby/ and http://ruby-doc.org/core-2.5.0/ 

Both are useful for learning Ruby, but if you want to just look something up, it's much easier to look things up in the core docs than in the book... But you're not going to read the core docs front to back.

I want the core docs. the rails guides are the book.  

On Tuesday, March 27, 2018 at 5:18:29 PM UTC-4, nanaya wrote:


On Wed, Mar 28, 2018, at 04:39, Brian Postow wrote:
> The rails guides are not references. They're tutorials.
>
> An example of the thing I'm having trouble with:
>
> I'm having things like "it says it's missing foo_bar_bazes" but
> "foo_bar_bazes" never occurs in my code, why does it think that it SHOULD?"
> The answer in this particular case was that there was a FooBarBaz or  
> something, and that Rails decided that there obviously should be a
> foo_bar_bazes sql table, which I never created. Rails was RIGHT, there
> needed to be a sql table, but it took me like 4 hours to figure out what it
> was complaining about, and where it thought "foo_bar_bazes" needed to live,
> and why it should be foo_bar_bazes and not FooBarBaz, or FooBarBazes or
> foo_bar_baz, or any other of a number of possible things... It took another
> 4 person hours to figure out how to get migrate to correctly do the things
> I needed, because it converted Camel to snake in ways that I didn't expect.
>
>

http://guides.rubyonrails.org/active_record_basics.html#naming-conventions

By default, Active Record uses some naming conventions to find out how the mapping between models and database tables should be created. Rails will pluralize your class names to find the respective database table. So, for a class Book, you should have a database table called books. The Rails pluralization mechanisms are very powerful, being capable of pluralizing (and singularizing) both regular and irregular words. When using class names composed of two or more words, the model class name should follow the Ruby conventions, using the CamelCase form, while the table name must contain the words separated by underscores. Examples:



http://guides.rubyonrails.org/active_record_migrations.html#creating-a-migration

Migrations are stored as files in the db/migrate directory, one for each migration class. The name of the file is of the form YYYYMMDDHHMMSS_create_products.rb, that is to say a UTC timestamp identifying the migration followed by an underscore followed by the name of the migration. The name of the migration class (CamelCased version) should match the latter part of the file name. For example 20080906120000_create_products.rb should define class CreateProducts and 20080906120001_add_details_to_products.rb should define AddDetailsToProducts. Rails uses this timestamp to determine which migration should be run and in what order, so if you're copying a migration from another application or generate a file yourself, be aware of its position in the order.



http://guides.rubyonrails.org/association_basics.html#detailed-association-reference

When you declare a belongs_to association, the declaring class automatically gains five methods related to the association:

...

When you declare a has_one association, the declaring class automatically gains five methods related to the association:

...


Not sure where you got the idea it's not references.

Oh and here's the documentation for autoloading mechanism (re: "Given a name of a given form, what kind of thing does RoR think it is and where is RoR looking for it?"):

http://guides.rubyonrails.org/autoloading_and_reloading_constants.html

--
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/c09de860-f182-43d2-b980-5b42fdd4d0c8%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/CACMkcE5JyOx4ppKSKTpUm9wr2-1cnhxyTQ9GEfKV2gfxUWfQ8Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails Tuesday, March 27, 2018

If I have auctions with end datetimes and bids for the auctions how do i have rails manage the end of the auctions

--
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/3d1fc89b-9ca8-428d-b837-5461a921c732%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hello,
  I an interested,
  CV: http://shahid-ansari.herokuapp.com/

On Monday, March 5, 2018 at 8:51:32 PM UTC+5:30, Sergio Lapenna wrote:
Hi guys,

we are looking for remote RoR developers to help us in the development of the server side of our IoT technology.

Best regards,
Sergio L.
Founder & CEO at RT
www.rtsrl.eu

Linkedin
: http://bit.ly/2oJqh99
Location: Italy
Languages: Italian, English

--
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/a301c23a-3156-4924-8fa4-a7909a9c3108%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Tuesday, March 27, 2018 at 2:12:27 PM UTC-4, Walter Lee Davis wrote:
Read the docs I linked you to, and if that doesn't explain it, then ask the author of the code you're extending. It's possible that it is passing a reference to a proc or lambda, but I have not seen that exact code before, so I can only guess.

Walter

> On Mar 27, 2018, at 2:04 PM, fugee ohu <fuge...@gmail.com> wrote:
>
> Thanks Walter And passing a symbol to message: how does that work?
>
>

I changed it to 
validate :auction_active?, message: self.errors
and now page loads without any errors

--
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/174e8b7e-afc4-48fd-8288-511a2556f49a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

by "not references" I meant it's way too verbose for what I need. The rails guides are meant (or appear to be meant) to be read cover to cover. I need something where I can looks a specific thing up.

It's the difference between http://ruby-doc.com/docs/ProgrammingRuby/ and http://ruby-doc.org/core-2.5.0/ 

Both are useful for learning Ruby, but if you want to just look something up, it's much easier to look things up in the core docs than in the book... But you're not going to read the core docs front to back.

I want the core docs. the rails guides are the book.  

On Tuesday, March 27, 2018 at 5:18:29 PM UTC-4, nanaya wrote:


On Wed, Mar 28, 2018, at 04:39, Brian Postow wrote:
> The rails guides are not references. They're tutorials.
>
> An example of the thing I'm having trouble with:
>
> I'm having things like "it says it's missing foo_bar_bazes" but
> "foo_bar_bazes" never occurs in my code, why does it think that it SHOULD?"
> The answer in this particular case was that there was a FooBarBaz or  
> something, and that Rails decided that there obviously should be a
> foo_bar_bazes sql table, which I never created. Rails was RIGHT, there
> needed to be a sql table, but it took me like 4 hours to figure out what it
> was complaining about, and where it thought "foo_bar_bazes" needed to live,
> and why it should be foo_bar_bazes and not FooBarBaz, or FooBarBazes or
> foo_bar_baz, or any other of a number of possible things... It took another
> 4 person hours to figure out how to get migrate to correctly do the things
> I needed, because it converted Camel to snake in ways that I didn't expect.
>
>

http://guides.rubyonrails.org/active_record_basics.html#naming-conventions

By default, Active Record uses some naming conventions to find out how the mapping between models and database tables should be created. Rails will pluralize your class names to find the respective database table. So, for a class Book, you should have a database table called books. The Rails pluralization mechanisms are very powerful, being capable of pluralizing (and singularizing) both regular and irregular words. When using class names composed of two or more words, the model class name should follow the Ruby conventions, using the CamelCase form, while the table name must contain the words separated by underscores. Examples:



http://guides.rubyonrails.org/active_record_migrations.html#creating-a-migration

Migrations are stored as files in the db/migrate directory, one for each migration class. The name of the file is of the form YYYYMMDDHHMMSS_create_products.rb, that is to say a UTC timestamp identifying the migration followed by an underscore followed by the name of the migration. The name of the migration class (CamelCased version) should match the latter part of the file name. For example 20080906120000_create_products.rb should define class CreateProducts and 20080906120001_add_details_to_products.rb should define AddDetailsToProducts. Rails uses this timestamp to determine which migration should be run and in what order, so if you're copying a migration from another application or generate a file yourself, be aware of its position in the order.



http://guides.rubyonrails.org/association_basics.html#detailed-association-reference

When you declare a belongs_to association, the declaring class automatically gains five methods related to the association:

...

When you declare a has_one association, the declaring class automatically gains five methods related to the association:

...


Not sure where you got the idea it's not references.

Oh and here's the documentation for autoloading mechanism (re: "Given a name of a given form, what kind of thing does RoR think it is and where is RoR looking for it?"):

http://guides.rubyonrails.org/autoloading_and_reloading_constants.html

--
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/c09de860-f182-43d2-b980-5b42fdd4d0c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Wed, Mar 28, 2018, at 04:39, Brian Postow wrote:
> The rails guides are not references. They're tutorials.
>
> An example of the thing I'm having trouble with:
>
> I'm having things like "it says it's missing foo_bar_bazes" but
> "foo_bar_bazes" never occurs in my code, why does it think that it SHOULD?"
> The answer in this particular case was that there was a FooBarBaz or
> something, and that Rails decided that there obviously should be a
> foo_bar_bazes sql table, which I never created. Rails was RIGHT, there
> needed to be a sql table, but it took me like 4 hours to figure out what it
> was complaining about, and where it thought "foo_bar_bazes" needed to live,
> and why it should be foo_bar_bazes and not FooBarBaz, or FooBarBazes or
> foo_bar_baz, or any other of a number of possible things... It took another
> 4 person hours to figure out how to get migrate to correctly do the things
> I needed, because it converted Camel to snake in ways that I didn't expect.
>
>

http://guides.rubyonrails.org/active_record_basics.html#naming-conventions

By default, Active Record uses some naming conventions to find out how the mapping between models and database tables should be created. Rails will pluralize your class names to find the respective database table. So, for a class Book, you should have a database table called books. The Rails pluralization mechanisms are very powerful, being capable of pluralizing (and singularizing) both regular and irregular words. When using class names composed of two or more words, the model class name should follow the Ruby conventions, using the CamelCase form, while the table name must contain the words separated by underscores. Examples:



http://guides.rubyonrails.org/active_record_migrations.html#creating-a-migration

Migrations are stored as files in the db/migrate directory, one for each migration class. The name of the file is of the form YYYYMMDDHHMMSS_create_products.rb, that is to say a UTC timestamp identifying the migration followed by an underscore followed by the name of the migration. The name of the migration class (CamelCased version) should match the latter part of the file name. For example 20080906120000_create_products.rb should define class CreateProducts and 20080906120001_add_details_to_products.rb should define AddDetailsToProducts. Rails uses this timestamp to determine which migration should be run and in what order, so if you're copying a migration from another application or generate a file yourself, be aware of its position in the order.



http://guides.rubyonrails.org/association_basics.html#detailed-association-reference

When you declare a belongs_to association, the declaring class automatically gains five methods related to the association:

...

When you declare a has_one association, the declaring class automatically gains five methods related to the association:

...


Not sure where you got the idea it's not references.

Oh and here's the documentation for autoloading mechanism (re: "Given a name of a given form, what kind of thing does RoR think it is and where is RoR looking for it?"):

http://guides.rubyonrails.org/autoloading_and_reloading_constants.html

--
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/1522185467.2857204.1318226216.161518C4%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

> On Mar 27, 2018, at 3:39 PM, Brian Postow <bpostow@gmail.com> wrote:
>
> No, I'm pretty sure that everything I'm looking at is strictly rails. A friend pointed me at: https://gist.github.com/iangreenleaf/b206d09c587e8fc6399e which is a really good start.
>
> All of the conversions of CamelCase to snake_case, or plural to singular are all strictly rails. AFAIK, the only thing Ruby cares about is capitalizing classes, maybe.
>
> The rails guides are not references. They're tutorials.
>
> An example of the thing I'm having trouble with:
>
> I'm having things like "it says it's missing foo_bar_bazes" but "foo_bar_bazes" never occurs in my code, why does it think that it SHOULD?" The answer in this particular case was that there was a FooBarBaz or something, and that Rails decided that there obviously should be a foo_bar_bazes sql table, which I never created. Rails was RIGHT, there needed to be a sql table, but it took me like 4 hours to figure out what it was complaining about, and where it thought "foo_bar_bazes" needed to live, and why it should be foo_bar_bazes and not FooBarBaz, or FooBarBazes or foo_bar_baz, or any other of a number of possible things... It took another 4 person hours to figure out how to get migrate to correctly do the things I needed, because it converted Camel to snake in ways that I didn't expect.
>
>

In that case, I suspect that you really ought to follow a single tutorial all the way through, even if you do know how to program. I really recommend the (free to use online) https://railstutorial.org by Michael Hartl. We use this at Penn for all new programmers, regardless of their existing experience with programming or Ruby or Rails. The last time I did it, it took me about two days to go from end to end (I take it over each time there's a new version, so I can advise the people I'm on-boarding). I've been using Rails professionally for over ten years, and I still learn things from it.

Following that exercise all the way through will give you an excellent tour of the many ways that Rails extends the Ruby language to make your day-to-day experience easier and faster (once you know the tricks).

You really won't get very far in Rails (with all your hair in place) if you don't follow the conventions it expects you to. There are ways around everything (self.table_name = 'BadLegacyTableName', for example, or self.primary_key = 'somethingRailsWontGuess'), but you can come to those after you learn what it expects by default. Being able to back a table with a form using an empty class of the proper name doesn't come for free (you have to follow the conventions to get it). If you're used to doing everything from scratch, you may not expect that to work, or know where to look when it doesn't.

Walter

> On Tuesday, March 27, 2018 at 1:09:46 PM UTC-4, Hassan Schroeder wrote:
> On Tue, Mar 27, 2018 at 6:52 AM, Brian Postow <bpo...@gmail.com> wrote:
>
> > I'm an experienced programmer, who's starting to use Ruby on Rails for the
> > first time. I need some documentation that JUST explains how variable names
> > are manipulated. Things I need to understand:
>
> The questions you're asking make me think you're conflating "Rails"
> and "Ruby". You might want to start at https://www.ruby-lang.org/
> with the "Ruby in 20 Minutes" and "Ruby From Other Languages"
> sections first.
>
> Aside from that, have you looked at the Rails guides? They might
> clarify some of your Rails-specific questions.
>
> http://guides.rubyonrails.org/
>
> 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/8df611da-76f3-4c75-b128-6bf2d6586c45%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/DE5AD2CF-FA0E-4511-B04A-89F63C6EFADB%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

No, I'm pretty sure that everything I'm looking at is strictly rails. A friend pointed me at: https://gist.github.com/iangreenleaf/b206d09c587e8fc6399e which is a really good start.

All of the conversions of CamelCase to snake_case, or plural to singular are all strictly rails. AFAIK, the only thing Ruby cares about is capitalizing classes, maybe.

The rails guides are not references. They're tutorials.

An example of the thing I'm having trouble with:

I'm having things like "it says it's missing foo_bar_bazes" but "foo_bar_bazes" never occurs in my code, why does it think that it SHOULD?" The answer in this particular case was that there was a FooBarBaz or  something, and that Rails decided that there obviously should be a foo_bar_bazes sql table, which I never created. Rails was RIGHT, there needed to be a sql table, but it took me like 4 hours to figure out what it was complaining about, and where it thought "foo_bar_bazes" needed to live, and why it should be foo_bar_bazes and not FooBarBaz, or FooBarBazes or foo_bar_baz, or any other of a number of possible things... It took another 4 person hours to figure out how to get migrate to correctly do the things I needed, because it converted Camel to snake in ways that I didn't expect.


On Tuesday, March 27, 2018 at 1:09:46 PM UTC-4, Hassan Schroeder wrote:
On Tue, Mar 27, 2018 at 6:52 AM, Brian Postow <bpo...@gmail.com> wrote:

> I'm an experienced programmer, who's starting to use Ruby on Rails for the
> first time. I need some documentation that JUST explains how variable names
> are manipulated. Things I need to understand:

The questions you're asking make me think you're conflating "Rails"
and "Ruby". You might want to start at  https://www.ruby-lang.org/
with the "Ruby in 20 Minutes" and "Ruby From Other Languages"
sections first.

Aside from that, have you looked at the Rails guides? They might
clarify some of your Rails-specific questions.

http://guides.rubyonrails.org/

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/8df611da-76f3-4c75-b128-6bf2d6586c45%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Read the docs I linked you to, and if that doesn't explain it, then ask the author of the code you're extending. It's possible that it is passing a reference to a proc or lambda, but I have not seen that exact code before, so I can only guess.

Walter

> On Mar 27, 2018, at 2:04 PM, fugee ohu <fugee279@gmail.com> wrote:
>
> Thanks Walter And passing a symbol to message: how does that work?
>
>

--
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/59801D36-D4F0-4032-920A-D16052AC3671%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails



On Tuesday, March 27, 2018 at 11:44:54 AM UTC-4, Walter Lee Davis wrote:

> On Mar 27, 2018, at 9:20 AM, fugee ohu <fuge...@gmail.com> wrote:
>
> Actually the first thing is see when I visit that link is the use of validate without the s

The validate method is used along with a custom validator method. The validates method is "built in" and uses a DSL to specify how you want the validations to work.

validate :has_a_bow_on_top?

private

def has_a_bow_on_top?
  unless bow&.on_top?
    errors[:bow].add "must be on top"
    false
  end
end

The built-in validates method is configured like this:

validates :bow, presence: true

This is a very basic example, there are lots more things you can do with it. For all of our sakes, please read this entire page: http://guides.rubyonrails.org/active_record_validations.html

Walter

>
> On Tuesday, March 27, 2018 at 6:54:34 AM UTC-4, Allen Maxwell wrote:
> It might help to have the models for auction and user... also, I like to add the annotate gem which gives some header comments in all my models to show what fields etc are there.  Very helpful info and references.
>
> you already know that the validate needs to be validates...
>
> is this an active system or SUD?  do you have a solid development database that is well populated to test/develop against?
>
> this link may help some:  http://guides.rubyonrails.org/active_record_validations.html#custom-methods
>
> other than that I'd have to see it in action to debug further.
>
> Good luck
>
> Max
>
> On Monday, March 26, 2018 at 6:17:56 PM UTC-6, fugee ohu wrote:
> This model has some errors that I wasn't able to get sorted out the two lines that begin with validate should be validates but after that I don't understand what the author's trying to do If I change them to validates I get the error Unknown validator: 'MessageValidator' for   validate :auction_active?, message: :auction_active
>
>
> class Bid < ActiveRecord::Base
>   belongs_to :auction
>   belongs_to :user
>
>   validates :auction, :user, presence: true
>   validate :auction_active?, message: :auction_active
>   validate :last_user_different?
>
>   scope :sorted, -> { order(:created_at) }
>
>   after_create :update_auction
>
>   private
>
>   def auction_active?
>     if auction && !auction.active?
>       if auction.finished?
>         errors.add(:auction, :finished)
>       else
>         errors.add(:auction, :not_started)
>       end
>     end
>   end
>
>   def last_user_different?
>     if auction && user
>       errors.add(:user, :same_user_twice) if auction.last_user == user
>     end
>   end
>
>   def update_auction
>     auction.increase_price_and_time
>     auction.publish_updates
>   end
> end
>
>
> --
> 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/b8ab4f9b-1682-4006-8d91-8f2c556f34e6%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


Thanks Walter And passing a symbol to message: how does that work? 

--
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/53605b52-f944-48fe-9a04-54a2b629d9a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

On Tue, Mar 27, 2018 at 6:52 AM, Brian Postow <bpostow@gmail.com> wrote:

> I'm an experienced programmer, who's starting to use Ruby on Rails for the
> first time. I need some documentation that JUST explains how variable names
> are manipulated. Things I need to understand:

The questions you're asking make me think you're conflating "Rails"
and "Ruby". You might want to start at https://www.ruby-lang.org/
with the "Ruby in 20 Minutes" and "Ruby From Other Languages"
sections first.

Aside from that, have you looked at the Rails guides? They might
clarify some of your Rails-specific questions.

http://guides.rubyonrails.org/

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

Ruby on Rails

> On Mar 27, 2018, at 9:20 AM, fugee ohu <fugee279@gmail.com> wrote:
>
> Actually the first thing is see when I visit that link is the use of validate without the s

The validate method is used along with a custom validator method. The validates method is "built in" and uses a DSL to specify how you want the validations to work.

validate :has_a_bow_on_top?

private

def has_a_bow_on_top?
unless bow&.on_top?
errors[:bow].add "must be on top"
false
end
end

The built-in validates method is configured like this:

validates :bow, presence: true

This is a very basic example, there are lots more things you can do with it. For all of our sakes, please read this entire page: http://guides.rubyonrails.org/active_record_validations.html

Walter

>
> On Tuesday, March 27, 2018 at 6:54:34 AM UTC-4, Allen Maxwell wrote:
> It might help to have the models for auction and user... also, I like to add the annotate gem which gives some header comments in all my models to show what fields etc are there. Very helpful info and references.
>
> you already know that the validate needs to be validates...
>
> is this an active system or SUD? do you have a solid development database that is well populated to test/develop against?
>
> this link may help some: http://guides.rubyonrails.org/active_record_validations.html#custom-methods
>
> other than that I'd have to see it in action to debug further.
>
> Good luck
>
> Max
>
> On Monday, March 26, 2018 at 6:17:56 PM UTC-6, fugee ohu wrote:
> This model has some errors that I wasn't able to get sorted out the two lines that begin with validate should be validates but after that I don't understand what the author's trying to do If I change them to validates I get the error Unknown validator: 'MessageValidator' for validate :auction_active?, message: :auction_active
>
>
> class Bid < ActiveRecord::Base
> belongs_to :auction
> belongs_to :user
>
> validates :auction, :user, presence: true
> validate :auction_active?, message: :auction_active
> validate :last_user_different?
>
> scope :sorted, -> { order(:created_at) }
>
> after_create :update_auction
>
> private
>
> def auction_active?
> if auction && !auction.active?
> if auction.finished?
> errors.add(:auction, :finished)
> else
> errors.add(:auction, :not_started)
> end
> end
> end
>
> def last_user_different?
> if auction && user
> errors.add(:user, :same_user_twice) if auction.last_user == user
> end
> end
>
> def update_auction
> auction.increase_price_and_time
> auction.publish_updates
> end
> end
>
>
> --
> 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/b8ab4f9b-1682-4006-8d91-8f2c556f34e6%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/9B8A922E-409D-4DBF-951D-8F01AD01A245%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Hello everyone, I'd like to have a better idea (that's up to date and real, not possibly fake data) of how much Web Developers / Programmers in different parts of the world are paid.

If anyone has 20 - 60 seconds to spare and fill the anonymous survey, it will be very helpful.

You will find the survey here:

After I get enough answers I'll also share the results in here, so others could benefit form it as well.

Thank you very much.

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

Ruby on Rails

Hello!

I'm an experienced programmer, who's starting to use Ruby on Rails for the first time. I need some documentation that JUST explains how variable names are manipulated. Things I need to understand:

  • When Rails will automatically convert between CamelCase and snake_case  (like How does migrate know to break up Add_Foo_Bar_Baz_To_Buq as adding a FooBarBaz column to the Buq table, and what will it to with Add_Foo_To_Baz_To_Buq or Add_FooBarBaz_To_Buq?)
  • When Rails will automatically convert between singular and plural
  • What the correct (conventional) form is for variables/class names/DB tables columns/method names of various types
  • Given a name of a given form, what kind of thing does RoR think it is and where is RoR looking for it?
  • Stuff like that...

I don't need a book that explains how to write a program from scratch (I have a large one that I'm already working with). I don't need something that explains how Ruby works, I can learn the language on my own. I need a reference where I can look things up easily.

Also, if there is a better resource to ask this question, that would be great as well. There doesn't appear to be a Stack Exchange site for asking resource recommendation questions...


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 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/79d6984f-6138-44c7-8f0a-89585bb010d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Actually the first thing is see when I visit that link is the use of validate without the s

On Tuesday, March 27, 2018 at 6:54:34 AM UTC-4, Allen Maxwell wrote:
It might help to have the models for auction and user... also, I like to add the annotate gem which gives some header comments in all my models to show what fields etc are there.  Very helpful info and references.

you already know that the validate needs to be validates...

is this an active system or SUD?  do you have a solid development database that is well populated to test/develop against?


other than that I'd have to see it in action to debug further. 

Good luck

Max

On Monday, March 26, 2018 at 6:17:56 PM UTC-6, fugee ohu wrote:
This model has some errors that I wasn't able to get sorted out the two lines that begin with validate should be validates but after that I don't understand what the author's trying to do If I change them to validates I get the error Unknown validator: 'MessageValidator' for   validate :auction_active?, message: :auction_active


class Bid < ActiveRecord::Base
  belongs_to :auction
  belongs_to :user

  validates :auction, :user, presence: true
  validate :auction_active?, message: :auction_active
  validate :last_user_different?

  scope :sorted, -> { order(:created_at) }

  after_create :update_auction

  private

  def auction_active?
    if auction && !auction.active?
      if auction.finished?
        errors.add(:auction, :finished)
      else
        errors.add(:auction, :not_started)
      end
    end
  end

  def last_user_different?
    if auction && user
      errors.add(:user, :same_user_twice) if auction.last_user == user
    end
  end

  def update_auction
    auction.increase_price_and_time
    auction.publish_updates
  end
end

--
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/b8ab4f9b-1682-4006-8d91-8f2c556f34e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

Ok, and I don't understand what this means:
validates :auction_active?, message: :auction_active

class Auction < ActiveRecord::Base
  include ApplicationHelper

  belongs_to :product
  belongs_to :image
  has_many :bids

  validates :product, :image, :min_price, :start_price, :start_time, :duration, :bid_time_step, :bid_price_step, presence: true
  validates :duration, :bid_time_step, numericality: { only_integer: true }
  validates :min_price, :start_price, :bid_price_step, numericality: { greater_than_or_equal_to: 0.01 }
  validates :min_price, :start_price, :bid_price_step, fractionality: { multiplier: 0.01 }

  after_initialize do
    self.start_time = Time.now.round_by(15.minutes) if self.new_record? && self.start_time.nil?
  end

  before_create { |auction| auction.price = auction.start_price }

  def self.finished_soon
    # TODO: use PostgreSQL
    Auction.all.select { |a| (a.time_left <= 5.seconds) && (a.time_left > 1.second) }
  end

  def started?
    start_time < Time.now
  end

  def finished?
    time_left < 0
  end

  def active?
    started? && !finished?
  end

  def time_left
    finish_time - Time.now
  end

  def start_in
    start_time - Time.now
  end

  def finish_time
    start_time + duration.seconds
  end

  def last_user
    bids.sorted.last.user if bids.any?
  end

  def increase_price_and_time
    self.price += self.bid_price_step
    self.duration += self.bid_time_step
    self.save!
  end

  def publish_updates
    PrivatePub.publish_to '/auctions/update', auction_id: self.id, time_left: status_desc(self), price: self.price
  end
end


On Tuesday, March 27, 2018 at 6:54:34 AM UTC-4, Allen Maxwell wrote:
It might help to have the models for auction and user... also, I like to add the annotate gem which gives some header comments in all my models to show what fields etc are there.  Very helpful info and references.

you already know that the validate needs to be validates...

is this an active system or SUD?  do you have a solid development database that is well populated to test/develop against?


other than that I'd have to see it in action to debug further. 

Good luck

Max

On Monday, March 26, 2018 at 6:17:56 PM UTC-6, fugee ohu wrote:
This model has some errors that I wasn't able to get sorted out the two lines that begin with validate should be validates but after that I don't understand what the author's trying to do If I change them to validates I get the error Unknown validator: 'MessageValidator' for   validate :auction_active?, message: :auction_active


class Bid < ActiveRecord::Base
  belongs_to :auction
  belongs_to :user

  validates :auction, :user, presence: true
  validate :auction_active?, message: :auction_active
  validate :last_user_different?

  scope :sorted, -> { order(:created_at) }

  after_create :update_auction

  private

  def auction_active?
    if auction && !auction.active?
      if auction.finished?
        errors.add(:auction, :finished)
      else
        errors.add(:auction, :not_started)
      end
    end
  end

  def last_user_different?
    if auction && user
      errors.add(:user, :same_user_twice) if auction.last_user == user
    end
  end

  def update_auction
    auction.increase_price_and_time
    auction.publish_updates
  end
end



class User < ActiveRecord::Base
  has_many :authorizations
  has_many :bids
  has_one :avatar
  belongs_to :role
  has_many :permissions, through: :role

  validates :nickname, presence: true
  validates :nickname, uniqueness: { case_sensitive: false }

  accepts_nested_attributes_for :avatar

  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable,
         :omniauthable, omniauth_providers: [:facebook, :vkontakte]

  before_create { |user| user.role = Role.default_role unless user.role }

  scope :bots, -> { where(role: Role.bot) }

  def self.random_bot
    bots.order('RANDOM()').first
  end

  def admin?
    role == Role.admin
  end

  def bot?
    role == Role.bot
  end

  def self.find_for_oauth(auth)
    authorization = Authorization.where(provider: auth.provider, uid: auth.uid.to_s).first
    if authorization
      user = authorization.user
    else
      email = auth.info[:email]
      nickname = auth.info[:nickname]
      user = User.where(email: email).first
      if user
        user.create_authorization(auth)
      elsif email.present? && nickname.present?
        password = Devise.friendly_token[0, 20]
        user = User.create(email: email, password: password, password_confirmation: password, nickname: nickname)
        user.create_authorization(auth)
      end
    end
    user
  end

  def create_authorization(auth)
    self.authorizations.create!(provider: auth.provider, uid: auth.uid)
  end

  def add_authorization(auth)
    authorization = Authorization.where(provider: auth.provider, uid: auth.uid.to_s).first
    if authorization
      authorization.user == self
    else
      create_authorization(auth)
      true
    end
  end
end



--
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/394b4c7e-27e7-4e39-b9f1-1164887c5eda%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.