Re: [Rails] Action Controller: Exception caught.

2020-03-23 Thread Walter Lee Davis
It appears that you have configured a database, but that database isn't running 
correctly, or doesn't have a user named "root". That name is commonly used in a 
default MySQL install. If you're using a different database engine, then the 
default user may be named differently. That's where I would start looking. The 
answer will be very specific to your own server.

Walter

> On Mar 23, 2020, at 11:11 AM, Thouba Nahakpam  wrote:
> 
> Hello,
> When I try to access localhost:3000, it shows ActiveRecord::NoDatabaseError. 
> Can anybody tell me how to fix it? I have attached a screenshot of it below.
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/980a2a38-5cf3-4b4d-9e39-582e47604538%40googlegroups.com.
> 

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/55386CC9-BBEB-407B-97F7-4AC0B0598CE0%40wdstudio.com.


Re: [Rails] webrtc - anyone done multi video ?

2020-03-20 Thread Walter Lee Davis
I meant, specifically, their new open-source video offering. They have a bunch 
of quick-start code that you can use to build a whole custom videoconferencing 
rig. I haven't dug into it in depth, but Twilio usually do a very thorough job 
of documenting (and writing) their applications.

Walter

> On Mar 19, 2020, at 9:59 PM, tom  wrote:
> 
> yes thank you, used them for sms...
> 
> 
> 
> On Thu, Mar 19, 2020, 5:18 PM Walter Lee Davis  wrote:
> Have you looked at this yet? https://www.twilio.com/docs/video
> 
> Walter
> 
> > On Mar 19, 2020, at 5:00 PM, tom  wrote:
> > 
> > hi,
> > 
> > i have just finished a webrtc chat via action cable, but before spending 
> > even more time on it trying to get video on as well, i was wondering if 
> > anyone can share any 'tips' or guides.
> > 
> > thank you all in advance
> > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google Groups 
> > "Ruby on Rails: Talk" group.
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to rubyonrails-talk+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMdTHiBGBC86ztTr79JnV_qEdLAn%2BPMJ%3Dyx1H%2Bm%3Drs2HMA%40mail.gmail.com.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/73986EB7-E20F-4162-B087-580EB3DA2481%40wdstudio.com.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMfLhswbc_HWDGGXBFZQAeiYZeGgj7wN-CgeKF0dxcR-%3DA%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/E47AF41E-F381-4050-824D-427AC7E9ADFB%40wdstudio.com.


Re: [Rails] webrtc - anyone done multi video ?

2020-03-19 Thread Walter Lee Davis
Have you looked at this yet? https://www.twilio.com/docs/video

Walter

> On Mar 19, 2020, at 5:00 PM, tom  wrote:
> 
> hi,
> 
> i have just finished a webrtc chat via action cable, but before spending even 
> more time on it trying to get video on as well, i was wondering if anyone can 
> share any 'tips' or guides.
> 
> thank you all in advance
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMdTHiBGBC86ztTr79JnV_qEdLAn%2BPMJ%3Dyx1H%2Bm%3Drs2HMA%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/73986EB7-E20F-4162-B087-580EB3DA2481%40wdstudio.com.


Re: [Rails] Is it worth switching to Postgresql?

2020-03-14 Thread Walter Lee Davis



> On Mar 14, 2020, at 12:17 PM, Rob Jonson  wrote:
> 
> thanks folks,
> 
> I guess I'm asking more about the practical pain points. - As you say, I 
> trust rails to deal with most of the day-to-day.
> 
> do you end up battling to get your postgres install working after upgrading 
> mac (or postgres?)

You can install Postgres as a user-space application (with an icon and 
everything), so this can be a non-issue.

> do you have problems with string encoding incompatibilities in obscure email 
> addresses?

If it doesn't fit into UTF-8, then you may have a problem. Do you have a 
problem now, in MySQL? What encoding and charset are you using now?

> do you have a convenient gui for browsing (like SequelPro)

TablePlus is pretty nice.

> are there other similar annoyances, or does it 'just work'

Like another commenter posted, I have used it on Heroku with SQLite on the dev 
side, and no issues.

> 
> whatever I use, I like to stick with the same db in dev & production, ( using 
> mysql or sqlite for my tests and postgres on the server seems like it is 
> asking for trouble)

It could be a problem, or it could be a sign that you are depending on a 
database feature to hide a bug. At work, we use SQLite for testing (including 
the CI stuff on GitLab) and Oracle on the production server. We try for 100% 
test coverage. 

Walter

> 
> cheers,
> 
> Rob
> 
> 
> 
> 
> On Sat, 14 Mar 2020 at 15:17, Phil Edelbrock  wrote:
> 
> I think Ariel's reply is spot-on.  Rails is basically DB agnostic, however I 
> think the trend is that PostgreSQL is the more favored backend (except for 
> stuff like Wordpress).  We're doing a lot more SQL procedural stuff these 
> days with our rails apps (e.g. kicking out JSON from a single query can be 
> literally 1,000x times faster in cases vs. asking Rails to query a model and 
> format the same thing).  I find PostgreSQL a lot easier to admin as well, but 
> to each their own.
> 
> Good luck!
> 
> 
> Phil
> 
> 
>> On Mar 14, 2020, at 7:37 AM, Ariel Juodziukynas  wrote:
>> 
>> Usually ActiveRecord takes care of most of the differences, and postresql 
>> has a lot of similarities with mysql. I guess it would be a different call 
>> if you ask about learning a completely different db engine like mongo or 
>> graphql, but learning postgresql shouldn't take too much time knowing MySQL, 
>> at least to be proficient. I even have a project that I used sqlite to 
>> prototype and postresql when deploying it to heroku for tests and I had to 
>> do nothing to make it work on both databases thanks to AR.
>> 
>> Also, heroku prefers postrgres for example and heroku is really popular for 
>> rails hosting.
>> 
>> El sáb., 14 mar. 2020 a las 10:58, Rob Jonson () 
>> escribió:
>> Hi Folks,
>> 
>> I have been using Mysql for forever, and broadly it works fine for me, with 
>> two complaints
>> 1) occasional issues with mismatches in encoding/collation on strings
>> 2) hours lost on every mac upgrade trying to get mysql working properly again
>> 
>> I know that people are generally favouring postgresql these days, I'm 
>> wondering if anyone can comment on whether it's worth putting in the effort 
>> to learn a new db?
>> 
>> all the best
>> 
>> Rob
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ruby on Rails: Talk" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to rubyonrails-talk+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/rubyonrails-talk/495925de-561d-4561-bb70-dfe9549219a8%40googlegroups.com.
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Ruby on Rails: Talk" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to rubyonrails-talk+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcBqX0Y3R_63yfarpdV%2B0qesh3VGzeTzP2bV0inbGMxoOQ%40mail.gmail.com.
> 
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/rubyonrails-talk/HjmTuU1QoNM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/BE54840B-0F95-4AB6-831B-90A3205AD2A6%40gmail.com.
> 
> 
> -- 
> 
> 
> 
> 
> 
> Hobbyist Software is a trading name of Hobbyist Software Limited. Registered 
> office 12 Fraley Rd, Bristol, BS93BS. Registered in England. Company 
> no:7876492
> 
> -- 
> 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 

Re: [Rails] Suggestions on how I should handle licensing in a session

2020-03-13 Thread Walter Lee Davis
That's what I would do. It's very low-drag that way. If you are 
horizontally-scaled, then you need to ensure that you have a central session 
store.

Walter

> On Mar 13, 2020, at 10:16 AM, John Sanderbeck  wrote:
> 
> In an app I wrote I implemented licensing for the modules in the app.
> 
> Right now, I query the database every time the license is checked which is a 
> ton of SQL calls per user per session...
> 
> How can I limit the lookup to once per session?
> 
> Just store it in the session hash?
> 
> John
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/9bbe311f-fcda-45bb-8357-10f14ebde9ea%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/0DEE97B2-EE1F-444D-B323-EF94125FBE75%40wdstudio.com.


Re: [Rails] add user_id to new record

2020-03-02 Thread Walter Lee Davis
In your Controller's #new and #create methods, scope the post to be owned by 
the current_user (or whatever other scheme you may be using for your 
logged-in-user management).

def new
  @post = current_user.posts.build
end

def create
  @post = current_user.posts.create(post_params)
  ...
end

Now your relationship will take care of getting the correct user in there 
automatically, whether it's in-memory or in persistence.

NB: If this doesn't appear to work, then you haven't built your relationships 
correctly, and you need to fix that before proceeding.

Walter

> On Mar 2, 2020, at 12:59 AM, fugee ohu  wrote:
> 
> How do i add user_id to a new record without placing it in a form as a hidden 
> field? I tried adding in the controller's create action just before `if 
> @post.save?` but that didn't cause new records created to have a value for 
> user_id Maybe it was because I'm using a nested form and this record is a 
> child record
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/3903125c-1f66-4ed3-89dd-b73620d797f2%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/48BB2E5C-C543-4ACA-BA4F-CB474CB9256A%40wdstudio.com.


Re: [Rails] do i need associations to use fields_for

2020-02-16 Thread Walter Lee Davis
You may use fields_for for any object that you have declared 
"accepts_nested_attributes_for" in your form's parent model. It obviously makes 
the most sense to do this with a related object.

Walter

> On Feb 16, 2020, at 10:41 PM, fugee ohu  wrote:
> 
> Can I use fields_for for any models or do they have to be associated?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/09881329-3137-4c90-94a1-6495bccc90bd%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/759C296E-0C97-47A2-9C0E-0088DFBFFB17%40wdstudio.com.


Re: [Rails] redirect shown in log, but browser not redirecting

2020-02-14 Thread Walter Lee Davis
Is your form set to the default of an Ajax submission, or did you add the 
configuration flag to the form_with method call that makes it actually 
redirect? If this was a redirect, the header would be 301, not 200. 

Walter

> On Feb 14, 2020, at 9:59 AM, fugee ohu  wrote:
> 
> 
> This is a redirect from my log, but page doesn't change I'm still on the same 
> page containing the form I submitted
> 
> 127.0.0.1 - - [14/Feb/2020:11:55:46 EST] "GET /artists/72/press_releases 
> HTTP/1.1" 200 2542
> http://localhost:3000/artists/72/tours/1 -> /artists/72/press_releases
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/be527a35-e686-4968-8849-ca05ecfc2491%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/E0E40135-7799-48A5-B2B9-1F6ACF93981C%40wdstudio.com.


Re: [Rails] how do i append an image to a dom element using javascript

2020-01-29 Thread Walter Lee Davis
https://lmgtfy.com/?q=how+do+i+append+an+image+to+a+dom+element+using+javascript

> On Jan 29, 2020, at 12:18 AM, fugee ohu  wrote:
> 
> how do i append an image to a dom element using javascript
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/a3f1366c-1bbb-4363-8a06-65b538719a32%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/537A0271-F027-4A15-8C70-398D9F0BFBDF%40wdstudio.com.


Re: [Rails] How do I prevent rails from redirecting to request referrer after create

2020-01-27 Thread Walter Lee Davis
You can define (in your controller) what the create action is after a 
successful save, and if you only want to do that for one format, and not the 
others, you can use the usual method for doing that in a controller, with:

if @foo.create(foo_params)
  respond_to do |format|
if format.js
  render status: :ok 
else
  redirect_to @foo
end
  end
else
  render :new
end

Using render status: :ok on success will not let anything else happen, no 
redirect, nothing changes on screen.

Walter


> On Jan 27, 2020, at 8:48 PM, fugee ohu  wrote:
> 
> I'm broadcasting to a javascript channel in my create action instead of 
> redirecting but rails redirects to request referrer
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/1b7ecb28-06c2-4638-9a37-221bf911da28%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/0DFFE05C-4FD0-468A-9086-2FD0B6420749%40wdstudio.com.


Re: [Rails] how do i send pictures in channels?

2020-01-19 Thread Walter Lee Davis



> On Jan 19, 2020, at 4:10 PM, fugee ohu  wrote:
> 
> Got my chat app working in rails 6 with channels but now how do I let users 
> send  pictures in channels? I've seen chat apps where after you upload the 
> picture it displays with a circled button that says send and you can also 
> delete it instead How do I do that?
> 

With JavaScript. One of the neatest implementations I've seen of this is in 
Trix (ActionText), which is open-source, so you could see how they do it there. 
Also GitLab has a nice one, and the source is available for that (unlike 
GitHub, who also have one). You're basically intercepting the drop and paste 
events, checking to see whether the payload was an image, and then doing some 
out-of-band trickery to make a file attachment using a separate model and 
controller. Trix uses the new ActiveStorage goodies for its implementation. Not 
sure what the others use.

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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/73566896-9468-43EB-BB2F-D05868DC64C4%40wdstudio.com.


Re: [Rails] How do I let users design their own blog with trix

2020-01-18 Thread Walter Lee Davis



> On Jan 17, 2020, at 6:29 PM, fugee ohu  wrote:
> 
>  I know how to use trix in a field but how do I let users design their entire 
> page?
> 

Trix is designed to be low- or no-design. The kinds of elements you can create 
with it (H1, P, FIGURE, UL, OL) are not, on their own, enough to create more 
than a word-processing-style page "layout". You could let the user have access 
to a stylesheet, and they could write some clever CSS, like, say, targeting the 
third paragraph and making it a pull-quote, with borders and margins and float, 
but that's not really the same thing as giving someone a full set of WYSIWYG 
controls where they can make the page look like anything they want.

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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/86469CAE-76D9-4426-995D-89605F5C78D0%40wdstudio.com.


Re: [Rails] where do i put my production mail server settings?

2020-01-16 Thread Walter Lee Davis



> On Jan 16, 2020, at 6:19 PM, fugee ohu  wrote:
> 
> 
> 
> On Monday, December 30, 2019 at 2:48:06 PM UTC-5, Walter Lee Davis wrote:
> 
> 
> > On Dec 29, 2019, at 11:44 PM, fugee ohu  wrote: 
> > 
> > I searched my entire tree starting at / for the name of my mail server but 
> > didn't find it Everything's working it sends mail in production just fine 
> > but I'm trying to figure out how, since it seems I never put the url of my 
> > mail server anywhere? 
> 
> Your production server may be set up with postfix or sendmail, and thus the 
> default (SMTP to localhost) will Just Work™. When your application sends 
> mail, it just sends a raw SMTP message to port 25 on the localhost, and the 
> mail server running there accepts it and forwards it. That's the default, 
> baked into Rails, in case you don't configure anything more specific. 
> 
> This is almost never what you actually want, because unless your production 
> Web server is also set up as an authoritative (DNS-verified) SMTP server, 
> your mail delivery will be spotty at best to large (think Gmail) recipients. 
> Those services take spam very seriously, and you have to climb over some tall 
> fences (configured in DNS, mainly, through TEXT and MX records) in order to 
> please them enough to accept your messages. 
> 
> This is doubly-true if your application is designed to send mail that is 
> "apparently-from" someone who is not at your server's domain. Services like 
> SendGrid exist to take this pain away from you, making sending transactional 
> e-mail as pain-free as possible, because they work to ensure that their 
> servers don't end up on banned lists, or get off them quickly. 
> 
> My recommendation if you want to send mail out to one user that appears to be 
> from another user, such that they can just hit "reply" in their mail 
> application and respond to it, send the message with the headers From: 
> a-real-...@your-server.com, and Reply-to: us...@example.com. That way the 
> message is deliverable (since it came from you, and you authenticate that in 
> your DNS settings), but the recipient can simply press Reply and not have to 
> manually correct the To: address in that message. 
> 
> Walter
> 
> I found google was rejecting mail from my server because I didn't DKIM and 
> DMARC signatures setup After adding the services how do I ask google to 
> re-review my mail server if I'm not using gsuite?
> 

I'm pretty sure it's done on a message-by-message basis. I doubt they maintain 
a ban-list that you're on, and have to remove you from. Each message 
purportedly "from" some other address is a new and special thing, since headers 
are so very easy to forge.

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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/9FB722B6-1423-494F-B0B9-409068C7D831%40wdstudio.com.


Re: [Rails] where do i put my production mail server settings?

2019-12-30 Thread Walter Lee Davis



> On Dec 29, 2019, at 11:44 PM, fugee ohu  wrote:
> 
> I searched my entire tree starting at / for the name of my mail server but 
> didn't find it Everything's working it sends mail in production just fine but 
> I'm trying to figure out how, since it seems I never put the url of my mail 
> server anywhere?

Your production server may be set up with postfix or sendmail, and thus the 
default (SMTP to localhost) will Just Work™. When your application sends mail, 
it just sends a raw SMTP message to port 25 on the localhost, and the mail 
server running there accepts it and forwards it. That's the default, baked into 
Rails, in case you don't configure anything more specific.

This is almost never what you actually want, because unless your production Web 
server is also set up as an authoritative (DNS-verified) SMTP server, your mail 
delivery will be spotty at best to large (think Gmail) recipients. Those 
services take spam very seriously, and you have to climb over some tall fences 
(configured in DNS, mainly, through TEXT and MX records) in order to please 
them enough to accept your messages. 

This is doubly-true if your application is designed to send mail that is 
"apparently-from" someone who is not at your server's domain. Services like 
SendGrid exist to take this pain away from you, making sending transactional 
e-mail as pain-free as possible, because they work to ensure that their servers 
don't end up on banned lists, or get off them quickly. 

My recommendation if you want to send mail out to one user that appears to be 
from another user, such that they can just hit "reply" in their mail 
application and respond to it, send the message with the headers From: 
a-real-addr...@your-server.com, and Reply-to: u...@example.com. That way the 
message is deliverable (since it came from you, and you authenticate that in 
your DNS settings), but the recipient can simply press Reply and not have to 
manually correct the To: address in that message.

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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/7D8D634C-0390-4E76-8D9A-3BA941D1EA83%40wdstudio.com.


Re: [Rails] create chat view

2019-12-26 Thread Walter Lee Davis



> On Dec 24, 2019, at 4:38 AM, fugee ohu  wrote:
> 
> I'm trying to create a chat view where if the sender of the message is the 
> current user then the message is displayed on the right side and if the 
> sender is the other user then the message is displayed on the left So far 
> what I have doesn't right or left float the messages, they all appear in the 
> same column
> 
> chat.html.erb:
> 
> 
> Conversation with <%= @conversation_with.name %>
> 
> 
> <% @messages.each do |m| %>
> <% if m.sender=@conversation_with %>
> <%= m.content %>
> <% else %>
> <%= m.content %>
> <% end %>
> <% end %>
> 
> 
> application.scss:
> 
> .left-float
> {
> float: left;
> }
> 
> .right-float
> {
> float: right;
> }
> 

A span element is an "inline" element, like an individual character of text. It 
has no structure to it at all, unless you give it some by adding display: 
inline-block or display: block to it. If you change those spans to divs, you 
may see a different visual outcome, because divs are naturally display: block 
unless you direct otherwise. 

Also, by itself, float left and float right won't give you any visual feedback 
unless the floated element is narrower than its parent element. A 100% wide 
element floated left doesn't look any different than a 100% wide element 
floated right. If I wanted to make a set of chat bubbles, I might start with 
this:

span.chat {
  display: block;
  width: 80%;
  padding: .3em .9em;
  border-radius: 1em;
  background-color: #ccc;
  float: left;
}

span.chat.originator {
  float: right;
  background-color: #cad5ff;
  text-align: right;
}

And then amend the ERB to set the base class as well as add the override class 
when the message is by the person who started the chat. The result should be 
emitted like this:

foo bar baz
boo blarg blech

You could make this less specific, css-wise, by adding a "chat" class to the 
parent div, and then changing the selectors like this:

.chat span {
  /* same as first rule above */
}

.chat > .originator {
  /* same as the second rule above */
}


  foo bar baz
  boo blarg blech


Fool around with these ideas in a regular HTML file, previewed in a browser. 
Don't involve Rails in it at all. The problem is most likely in your HTML or 
CSS.

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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/5cee16be-a1df-4748-b842-7bfab60c9e5c%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/58342DD0-E4D0-436F-A6F7-7A010205AD02%40wdstudio.com.


Re: [Rails] rails g scaffold creates strange form

2019-12-15 Thread Walter Lee Davis



> On Dec 15, 2019, at 9:54 AM, fugee ohu  wrote:
> 
> How do I ensure that webpacker doesn't know anything about my favicon I 
> removed the favicon lines in application.js and renamed favicons.js to 
> favicons.js.renamed and than ran `rake webpacker:compile` (not that i know 
> what that's supposed to be for) but still the app is complaining favicon.ico 
> can't be found in manifest.js

I have no idea. This is not something I've encountered in my own apps, perhaps 
there is another manifest somewhere that is requiring it, since it was once 
added and attempted to compile.

I've just updated to Rails 6.0.2, in Ruby 2.6.5. Run rails new test-6, and 
after a mighty pause for gem compilation and so forth, 'Webpacker successfully 
installed :trumpet: :cake:' appears on my screen.

rails g scaffold Foo bar baz boo

And now, this:

rake webpacker:compile
Compiling...
Compiled all packs in /Users/waltd/Documents/sandbox/test-6/public/packs
Hash: 60efe71c97239d74f7f6
Version: webpack 4.41.2
Time: 3521ms
Built at: 12/15/2019 12:45:40 PM
Asset   Size  Chunks
 Chunk Names
   js/application-6297f63bc162c780afc3.js   69.2 KiB   0  [emitted] 
[immutable]  application
js/application-6297f63bc162c780afc3.js.br   15.3 KiB  [emitted] 
 
js/application-6297f63bc162c780afc3.js.gz   17.7 KiB  [emitted] 
 
   js/application-6297f63bc162c780afc3.js.map205 KiB   0  [emitted] 
[dev]application
js/application-6297f63bc162c780afc3.js.map.br   43.9 KiB  [emitted] 
 
js/application-6297f63bc162c780afc3.js.map.gz 51 KiB  [emitted] 
 
manifest.json  364 bytes  [emitted] 
 
 manifest.json.br  127 bytes  [emitted] 
 
 manifest.json.gz  142 bytes  [emitted] 
 
Entrypoint application = js/application-6297f63bc162c780afc3.js 
js/application-6297f63bc162c780afc3.js.map
[0] (webpack)/buildin/module.js 552 bytes {0} [built]
[1] ./app/javascript/packs/application.js 742 bytes {0} [built]
[5] ./app/javascript/channels/index.js 205 bytes {0} [built]
[6] ./app/javascript/channels sync _channel\.js$ 160 bytes {0} [built]
+ 3 hidden modules

No mention of missing anything, no mention of favicon in the context of JS at 
all.

No mention of favicon in the page head, either. So I remedied that:



And running this in rails server again gives me no issues with JS and favicon.

So clearly, your mileage varies, and that means that something you did with 
webpacker differs from what I did with webpacker. Since I did as little as 
possible, maybe you did too much one time, and it got stuck that way. Nuke the 
whole thing from orbit, and try again somewhere else, as Ripley might say.

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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/65DE6C93-4538-4731-ADA0-CE837265CAAF%40wdstudio.com.


Re: [Rails] rails g scaffold creates strange form

2019-12-14 Thread Walter Lee Davis
Sorry, I meant link tag, not meta tag.

Walter

> On Dec 14, 2019, at 2:31 PM, Walter Lee Davis  wrote:
> 
>  normal meta tag 

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/83FC28B0-EDB1-4CA0-9926-8AFD38D240CE%40wdstudio.com.


Re: [Rails] rails g scaffold creates strange form

2019-12-14 Thread Walter Lee Davis



> On Dec 14, 2019, at 4:42 AM, fugee ohu  wrote:
> 
> 
> 
> On Friday, December 13, 2019 at 9:41:29 PM UTC-5, Walter Lee Davis wrote:
> You're looking at the id. If you look at how the form renders in a browser, 
> the name property will be the usual Rails nested format: 
> 
>  id="auction_listing_start_date"> 
> 
> I can't be bothered to write out an entire set of select tags, just imagine 
> if datetime_select was written as date_tag. That's how it would render. 
> 
> Walter 
> 
> > On Dec 13, 2019, at 3:26 PM, fugee ohu  wrote: 
> > 
> > I mean the field names Instead of just fieldname it's tablename_fieldname 
> > 
> > -- 
> > 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 rubyonra...@googlegroups.com. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/rubyonrails-talk/f6241dbd-793c-4efc-b698-eb59d5ed22aa%40googlegroups.com.
> >  
> 
> Heh, yea you're right What versions of rails add the id for scaffold 
> generator? 

I believe this happened in 5.2, and it was a fix to a regression introduced in 
5.1, when they switched the form generator from form_for (which already had 
automatic IDs generated by the tag helpers) to form_with, which removed those. 

Rather than restoring the magical automatic ID attributes, the scaffold 
generator was updated to include the id: 'whatever_attribute' directive in the 
individual tags, and the tag helpers were left alone. 

Previously, if you wanted to suppress the ID for a form element (say, if you 
needed to have two or more identical elements on the page -- think: a bunch of 
checkboxes for the same attribute), you would have to pass id: nil or id: false 
(one of those) to the helper. Now, that's the default behavior, and if you want 
an ID at all, you have to tell it what you want that ID to be. I'm not sure 
where the edge case is here; whether it's more common to want no ID, or to have 
a nice unique one generated for you for free. It's clear what the framework 
designers chose.

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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/4ef93297-7203-45bb-a50e-4787856e05c1%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/84B2A9F2-CCA3-4B4F-8B96-2146D2E6F503%40wdstudio.com.


Re: [Rails] rails g scaffold creates strange form

2019-12-14 Thread Walter Lee Davis



> On Dec 14, 2019, at 4:50 AM, fugee ohu  wrote:
> 
> 
> 
> On Friday, December 13, 2019 at 9:41:29 PM UTC-5, Walter Lee Davis wrote:
> You're looking at the id. If you look at how the form renders in a browser, 
> the name property will be the usual Rails nested format: 
> 
>  id="auction_listing_start_date"> 
> 
> I can't be bothered to write out an entire set of select tags, just imagine 
> if datetime_select was written as date_tag. That's how it would render. 
> 
> Walter 
> 
> > On Dec 13, 2019, at 3:26 PM, fugee ohu  wrote: 
> > 
> > I mean the field names Instead of just fieldname it's tablename_fieldname 
> > 
> > -- 
> > 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 rubyonra...@googlegroups.com. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/rubyonrails-talk/f6241dbd-793c-4efc-b698-eb59d5ed22aa%40googlegroups.com.
> >  
> 
> 
> Can you help me with my other problem, favicon with webpacker? It's another 
> post Webpacker complains it can't find a compiled favicon.ico in 
> manifest.json I assume this means I'm missing an entry in package.json for 
> favicon.ico but I actually followed a tutorial called "bundle your favicons 
> with webpacker" 
> https://medium.com/tech-angels-publications/bundle-your-favicons-with-webpack-b69d834b2f53
>  I did exactly what the tutorial said but I get this error

I've never used webpacker for anything serious, and every time I have used it 
trivially, I have not configured anything manually. I would second the other 
advice you got in the original thread -- just ensure that webpacker doesn't 
know anything about your favicon, and let your Web server host it normally. 

Any regular (web-readable) file in the /public directory of your project will 
be served by your Web server without any interference by Rails or any form of 
its asset pipeline. Don't use the tag generator in your application.html.erb 
file, just use a normal meta tag as if you were hand-coding static HTML. The 
correct href to use is '/favicon.ico', and that maps directly to 
/path/to/your/application/public/favicon.ico.

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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/49177ce8-aa46-4fda-9158-20108029ab9e%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/B713AA62-47CE-4F4C-86E6-5800978B2519%40wdstudio.com.


Re: [Rails] rails g scaffold creates strange form

2019-12-13 Thread Walter Lee Davis
You're looking at the id. If you look at how the form renders in a browser, the 
name property will be the usual Rails nested format:

 

I can't be bothered to write out an entire set of select tags, just imagine if 
datetime_select was written as date_tag. That's how it would render.

Walter

> On Dec 13, 2019, at 3:26 PM, fugee ohu  wrote:
> 
> I mean the field names Instead of just fieldname it's tablename_fieldname
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/f6241dbd-793c-4efc-b698-eb59d5ed22aa%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/D9D072FB-ACC1-47B5-BE49-ECF3E823CA4F%40wdstudio.com.


Re: [Rails] rails g scaffold creates strange form

2019-12-13 Thread Walter Lee Davis



> On Dec 13, 2019, at 4:40 AM, fugee ohu  wrote:
> 
> In this form created by the scaffold generator all the field names are 
> prepended with the table_name plus underscore What causes this to happen in 
> rails 5.1.7
> 
>   
> <%= form.label :start_date %>
> <%= form.datetime_select :start_date, id: :auction_listing_start_date %>
>   
> 

Take a look at the `form_with` method at the top of the form. What is the 
variable declared inside the block at the end of that line? That's what you're 
seeing here, nothing more. The declared variable for the form builder is what 
precedes every form helper method inside the block. In the past, it was 
traditionally `f`. In never versions, they use `form`. It doesn't matter what 
you use, as long as it is consistent throughout the form_with or form_for block.

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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/75E7B1E2-51F5-4839-B4C9-EACCEB5E30D9%40wdstudio.com.


Re: [Rails] new action doesn't render from other model's index page

2019-12-01 Thread Walter Lee Davis



> On Dec 1, 2019, at 10:17 PM, fugee ohu  wrote:
> 
> A generic scaffold posts to the create action PATCH and PUT according to you 
> in this discussion POST to update Even still new is fetched by GET where 
> new.html.erb renders _form.html.erb  
> 
> 

I'm not sure if you're confused about what I wrote, or just confused. Here are 
the actual actions that a generic Rails 6 scaffold generates and responds to. 
Read the comments before each method:

class FoosController < ApplicationController
  before_action :set_foo, only: [:show, :edit, :update, :destroy]

  # GET /foos
  # GET /foos.json
  def index
@foos = Foo.all
  end

  # GET /foos/1
  # GET /foos/1.json
  def show
  end

  # GET /foos/new
  def new
@foo = Foo.new
  end

  # GET /foos/1/edit
  def edit
  end

  # POST /foos
  # POST /foos.json
  def create
@foo = Foo.new(foo_params)

respond_to do |format|
  if @foo.save
format.html { redirect_to @foo, notice: 'Foo was successfully created.' 
}
format.json { render :show, status: :created, location: @foo }
  else
format.html { render :new }
format.json { render json: @foo.errors, status: :unprocessable_entity }
  end
end
  end

  # PATCH/PUT /foos/1
  # PATCH/PUT /foos/1.json
  def update
respond_to do |format|
  if @foo.update(foo_params)
format.html { redirect_to @foo, notice: 'Foo was successfully updated.' 
}
format.json { render :show, status: :ok, location: @foo }
  else
format.html { render :edit }
format.json { render json: @foo.errors, status: :unprocessable_entity }
  end
end
  end

  # DELETE /foos/1
  # DELETE /foos/1.json
  def destroy
@foo.destroy
respond_to do |format|
  format.html { redirect_to foos_url, notice: 'Foo was successfully 
destroyed.' }
  format.json { head :no_content }
end
  end

  private
# Use callbacks to share common setup or constraints between actions.
def set_foo
  @foo = Foo.find(params[:id])
end

# Never trust parameters from the scary internet, only allow the white list 
through.
def foo_params
  params.require(:foo).permit(:bar, :baz)
end
end

Here's what I have gleaned from this exchange:

You want to start at the "index" view, and have a form on that page send a 
request to the "new" view, passing along a parameter that you will use to 
determine what `item_type` is to be created by the "create" method that the 
form on the "new" view will display.

On your Index page, here's what that form could look like:

<%= form_with url: 'foos/new', method: :get, local: true do |f| %>
<%= f.collection_select :item_type, %w[one two], :to_s, :titleize  %>
<%= f.submit 'Choose', name: nil %>
<%- end -%>

When that form is submitted, you will have access to either 'one' or 'two' in 
the params[:item_type] variable. You can do something interesting with that in 
the #new controller method. For a start, just to show that it worked, I changed 
the generic scaffold new.html.erb page to include this line:

New <%= params[:item_type].to_s.titleize %>

When I test that, I see either "New One" or "New Two" when that page loads, 
depending on the choice I made on the index page.

Try some of these suggestions in a new, scaffolded controller in a different 
Rails app (or the same one, if you've been keeping up with your version 
control). Just try it as a test, and see what you can learn.

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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/0753AE10-9331-4CBD-88CF-20DE2A0C8B42%40wdstudio.com.


Re: [Rails] new action doesn't render from other model's index page

2019-12-01 Thread Walter Lee Davis
Look at a generic Rails controller, fresh out of `rails generate scaffold foo 
bar baz`. You will see that the `foos/new` form posts to the /foos path. That's 
what I mean by "posts to the collection". Once an instance has been persisted, 
you will see that the `foos/1/edit` form sends a POST disguised as a PATCH or 
PUT to the instance, at foos/1, and the `update` method is invoked by the 
controller. But when you are first creating a new instance, you are sending a 
POST to /foos (the collection of Foo instances).

Don't try to create a separate form for each kind of thing you want to create 
yet, just focus for now on making the two-step "wizard" work. Once you have 
that working, you can use the controller's `new` method (which will be getting 
a parameter passed to it to say what the item_type is) to decide which form to 
render. But until you have that part figured out, don't waste your energy on 
rendering a different form.

Walter

> On Dec 1, 2019, at 3:17 PM, fugee ohu  wrote:
> 
> 
> 
> On Sunday, December 1, 2019 at 12:49:53 PM UTC-5, Walter Lee Davis wrote:
> That's just it, you don't. You POST to the collection, which `create`s a new 
> instance. 
> 
> If you are expecting the GET with a querystring to create a new form with a 
> picker selected, you should start by creating the form all in one piece, 
> where you create a new form including a select (like the one you are trying 
> to divide across two pages) in that same form. Make sure that submitting that 
> form works, even though it doesn't do precisely what you're asking it to do 
> in the divided form (yet). 
> 
> Then figure out how to set that property (which the select chooses) on the 
> `new` controller method. 
> 
> There's a couple of different ways to do that. One would be to create a 
> completely hand-made variable that you pass in the querystring of the form: 
> 
> /items/new?item_type=Foo 
> 
> and then "catch" that in the controller in the new method: 
> 
> @item = Item.new(item_type = params[:item_type]) 
> 
> The other would be to go full-on REST, and create a new instance in the 
> `index`, use that to build your form, and then you can use the regular 
> strong_params accessor to get that same value (which will be "nested" inside 
> a properly-named instance params hash) and assign it to the instance in the 
> `new` method. 
> 
> Now, what you should see at this point is that your all-in-one `new` form 
> begins to behave "automatically". The instance that you build in the 
> controller will be populated with the item_type property, and the picker will 
> auto-select to the chosen value. 
> 
> Once you see this working, you can change the select (picker) to a hidden 
> field, and with no other changes, you will have your two-step form. 
> 
> Walter 
> 
> > On Dec 1, 2019, at 12:17 PM, fugee ohu  wrote: 
> > 
> > Thanks but since when do we post to the new action? 
> > 
> > -- 
> > 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 rubyonra...@googlegroups.com. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/rubyonrails-talk/fd3f5207-840b-4fec-ba29-100fdf882447%40googlegroups.com.
> >  
> 
> 
> What does that mean? How do I POST to a collection which creates a new 
> instance
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/1a0cfa0a-8962-4aa6-ab89-b26a680dacb0%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/930A6D5B-B6D9-4526-BC6A-364338DC84FA%40wdstudio.com.


Re: [Rails] new action doesn't render from other model's index page

2019-12-01 Thread Walter Lee Davis
Sorry, typo here:

> On Dec 1, 2019, at 12:49 PM, Walter Lee Davis  wrote:
> 
> @item = Item.new(item_type = params[:item_type])

@item = Item.new(item_type: params[:item_type])

I meant hash syntax, not assignment.

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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/19B49E53-FDDF-4D4E-BE57-9BEE698BCA33%40wdstudio.com.


Re: [Rails] new action doesn't render from other model's index page

2019-12-01 Thread Walter Lee Davis
That's just it, you don't. You POST to the collection, which `create`s a new 
instance. 

If you are expecting the GET with a querystring to create a new form with a 
picker selected, you should start by creating the form all in one piece, where 
you create a new form including a select (like the one you are trying to divide 
across two pages) in that same form. Make sure that submitting that form works, 
even though it doesn't do precisely what you're asking it to do in the divided 
form (yet).

Then figure out how to set that property (which the select chooses) on the 
`new` controller method.

There's a couple of different ways to do that. One would be to create a 
completely hand-made variable that you pass in the querystring of the form:

/items/new?item_type=Foo

and then "catch" that in the controller in the new method:

@item = Item.new(item_type = params[:item_type])

The other would be to go full-on REST, and create a new instance in the 
`index`, use that to build your form, and then you can use the regular 
strong_params accessor to get that same value (which will be "nested" inside a 
properly-named instance params hash) and assign it to the instance in the `new` 
method.

Now, what you should see at this point is that your all-in-one `new` form 
begins to behave "automatically". The instance that you build in the controller 
will be populated with the item_type property, and the picker will auto-select 
to the chosen value. 

Once you see this working, you can change the select (picker) to a hidden 
field, and with no other changes, you will have your two-step form.

Walter

> On Dec 1, 2019, at 12:17 PM, fugee ohu  wrote:
> 
> Thanks but since when do we post to the new action? 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/fd3f5207-840b-4fec-ba29-100fdf882447%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/F38B1785-69F3-40DE-8E24-3C660B78A51D%40wdstudio.com.


Re: [Rails] new action doesn't render from other model's index page

2019-12-01 Thread Walter Lee Davis



> On Dec 1, 2019, at 8:08 AM, fugee ohu  wrote:
> 
> When I click submit nothing happens The console only shows the request
> 
> items/index.html.erb:
> 
> <%= form_with model: Item, url: new_item_path(@item), method: "get" do |f| %>

Your problem is right here. You are using a GET where you want a POST, and you 
are GETting the items/new path when you want to POST to the items path. Rails 
is particular about all of these points, because it is a (mostly standard) REST 
framework. When you change away from these conventions, you do so on your own. 
You can't expect Rails to know what you want this request to do, and you can't 
expect anyone who follows the usual patterns to be able to help you.

Walter

> 
>  
>  <%= f.select :item_type_id, nested_set_options(ItemType.all, 
> @item_type) {|i| "#{'-' * i.level} #{i.name}" }, {:include_blank => 
> "Select"}%>
>  
> 
> 
> <%= f.submit "New item" %>
> 
> 
> <% end %>
> 
> new.html.erb:
> 
> <%= render form %>
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/53e9cef1-537b-4b77-8693-91b0e343f565%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/4C27660A-81AA-4600-912F-C05BB69BACBC%40wdstudio.com.


Re: [Rails] how to use form_with

2019-11-18 Thread Walter Lee Davis
> On Nov 18, 2019, at 3:20 PM, fugee ohu  wrote:
> 
> 
> 
> On Monday, November 18, 2019 at 2:56:24 PM UTC-5, Rob Zolkos wrote:
> Have you read the Rails API docs and Rails Guides for usage of form_with?
> 
> https://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-form_with
> https://guides.rubyonrails.org/form_helpers.html
> 
> 
> 
> On Mon, Nov 18, 2019 at 2:25 PM fugee ohu  wrote:
> Trying to build a rails 5.2 form using form_with I get this error: 
> ActionView::Template::Error (wrong number of arguments (given 1, expected 0)):
> 
> <%= form_with @item, url: new_item_path, method: 'get' do |f| %>
> 
>  
> <%= f.select :item, :item_type_id, ItemType.all, :id, :name %>
>  
> 
> 
> <%= f.submit "New item" %>
> 
> 
> <% 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 rubyonra...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/06504cd7-6a1a-4d24-84a3-c63f5113197c%40googlegroups.com.
> 
> 
> 
> <%= form_with(model: @item, url: new_item_path(@item), method: "get") do |f| 
> %>
> 
>  
> <%= f.select :item, :item_type_id, ItemType.all, :id, :name %>
>  
> 
> 
> <%= f.submit "New item" %>
> 
> 
> <% end %>
> 
>  ActionView::Template::Error (wrong number of arguments (given 5, expected 
> 1..4)):
> 


Which item in the code you shared is being given five arguments? Look there. 
(It's not the form_for.)

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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/A07E9099-5EFC-49B5-8A93-169696B96FDD%40wdstudio.com.


Re: [Rails] build method

2019-11-01 Thread Walter Lee Davis



> On Nov 1, 2019, at 2:12 AM, fugee ohu  wrote:
> 
> 
> 
> On Friday, November 1, 2019 at 12:12:18 AM UTC-4, Ariel Juodziukynas wrote:
> If you have:
> item has_many item_item_properties
> item_item_property belongs_to item_property
> 
> then you can add a relationship on the item model
> 
> has_many :item_properties, through: :item_item_properties
> 
> Then you'll be able to call @item.item_properties to loop through the 
> ItemProperty objects associated to that Item object.
> 
> Now, you say @item.item_item_properties.pluck(:item_property_id) returns an 
> empty array, that's because the Item does not have associated properties and 
> pluck does an SQL.
> 
> El vie., 1 nov. 2019 a las 0:52, fugee ohu () escribió:
> 
> 
> On Thursday, October 31, 2019 at 11:32:22 PM UTC-4, Ariel Juodziukynas wrote:
> You can do @item.item_item_properties.each do |item_item_property| and handle 
> that object inside the loop, I'm not sure why would you expect that 
> item_item_properties relationship to return key, value pairs. I don't 
> understand what you want to achieve, maybe you are trying to do it on the 
> wrong path.
> 
> El vie., 1 nov. 2019 a las 0:27, fugee ohu () escribió:
> 
> 
> On Thursday, October 31, 2019 at 9:33:22 PM UTC-4, Ariel Juodziukynas wrote:
> @item.item_item_properties returns a collection of objects, you are calling a 
> method on something array-like, it makes no sense.
> 
> If you want to get all the item_property_ids you can do 
> @item.item_item_properties.pluck(:item_property_id) for example. I'm not sure 
> what you want to achieve.
> 
> El jue., 31 oct. 2019 a las 22:29, fugee ohu () escribió:
> 
> 
> On Thursday, October 31, 2019 at 2:15:48 PM UTC-4, Ariel Juodziukynas wrote:
> Use `.size` instead of `.count`. "count" does a database query and since you 
> only built the element the COUNT db query will return 0. "size" knows what to 
> do if the association is already initialized so it will return "1" in your 
> case (and if it's not already loaded it will run a COUNT db query).
> 
> El jue., 31 oct. 2019 a las 8:42, fugee ohu () escribió:
> > @item=Item.new
> > @item.item_item_properties.build
> > @item.item_item_properties.count
>  => 0
> 
> Why doesn't my @item object have any item_item_properties after build method 
> 
> -- 
> 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 rubyonra...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/161b90ed-b6b1-4d4d-9f67-fb70f0463621%40googlegroups.com.
> 
> How do I reference individual columns?
>  2.3.3 :006 > @item.item_item_properties.item_property_id
> NoMethodError: undefined method `item_property_id' for 
> #
> 
> 
> -- 
> 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 rubyonra...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/a80b3961-82df-4943-9e5a-adb764d516b7%40googlegroups.com.
> 
> Could I directly access key, value without pluck or otherwise like
>  @item.item_item_properties.each do |key, value|
> item_property_id
> 
> -- 
> 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 rubyonra...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/b2057f01-80e0-4816-8893-b783e30159f8%40googlegroups.com.
> 
> Display item_property attributes in form
> 
> -- 
> 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 rubyonra...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/3a2c3dcf-3b21-49c9-8e49-9b2f276d7b6d%40googlegroups.com.
> 
> There are no database records yet, we know, the object was instantiated by 
> the build method but so far I don't see how to read it's data for my views
> 

You're trying to build a nested form, with the possibility of adding N children 
to the parent form. When you build a new child object in memory, you need to 
create a form for that object dynamically. There's a Railscast about this idea, 
which you may find useful: 
http://media.railscasts.com/assets/episodes/videos/196-nested-model-form-revised.mp4

Here's a link to the article about that screencast: 
http://railscasts.com/episodes/196-nested-model-form-revised

Please note that these videos are very old, and the specific details may differ 
from modern Rails practice, but the ideas underlying them are sound, and still 
hold up 

Re: [Rails] help on building a microservice that can receive an uploaded image

2019-10-07 Thread Walter Lee Davis
You were honest about this being your "homework", which is good: many people 
try to ask the same sort of questions without that decency. I gave you a link 
to the documentation, which has examples for each of the methods in this module 
-- without seeing the rest of your work, I can't tell you more about how to 
integrate it there.

Walter

> On Oct 6, 2019, at 10:44 AM, bouazza Mohamed  wrote:
> 
> Do you have some examples for using this ,
> 
> I found cloudinary gem , they already did some good work on image management 
> pipeline.
> 
> On Sun, Oct 6, 2019 at 12:41 Walter Lee Davis  wrote:
> Ruby has SecureRandom for this sort of thing: 
> https://docs.ruby-lang.org/en/2.4.0/SecureRandom.html
> 
> Walter
> 
> > On Oct 6, 2019, at 5:08 AM, bouazza Mohamed  wrote:
> > 
> > Hi everyone ,
> > I have a job interview test   to build a simple microservice that can 
> > receive an uploaded image and return a unique identifier for the uploaded 
> > image that can be used subsequently to retrieve the image.
> > 
> > Do you have some ideas on lib and UUID that can be used . normaly in PHP 
> > there some can be done in help using this :
> > 
> > Link 1: https://github.com/ramsey/uuid
> > Link 2 : http://image.intervention.io/
> > 
> > 
> > Thank you all lot in advance 
> > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google Groups 
> > "Ruby on Rails: Talk" group.
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to rubyonrails-talk+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/rubyonrails-talk/01d77a84-f14a-477f-af8a-de1e94c47ed0%40googlegroups.com.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/76942266-AAA8-4795-824A-B6F4FE2E3311%40wdstudio.com.
> -- 
>   
> Mohamed
> about.me/mohamedbouazz
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/CAG%3DFY80z%2BQQkYgn_VwvdfB1ssrDjRk-Ma61tOSkieNtck-R8Vw%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/C7975863-2538-4111-956F-BE1555ABE98C%40wdstudio.com.


Re: [Rails] help on building a microservice that can receive an uploaded image

2019-10-06 Thread Walter Lee Davis
Ruby has SecureRandom for this sort of thing: 
https://docs.ruby-lang.org/en/2.4.0/SecureRandom.html

Walter

> On Oct 6, 2019, at 5:08 AM, bouazza Mohamed  wrote:
> 
> Hi everyone ,
> I have a job interview test   to build a simple microservice that can receive 
> an uploaded image and return a unique identifier for the uploaded image that 
> can be used subsequently to retrieve the image.
> 
> Do you have some ideas on lib and UUID that can be used . normaly in PHP 
> there some can be done in help using this :
> 
> Link 1: https://github.com/ramsey/uuid
> Link 2 : http://image.intervention.io/
> 
> 
> Thank you all lot in advance 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/01d77a84-f14a-477f-af8a-de1e94c47ed0%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/76942266-AAA8-4795-824A-B6F4FE2E3311%40wdstudio.com.


Re: [Rails] Why do I have to require bootstrap if I'm using the gem

2019-09-20 Thread Walter Lee Davis
If you mean in your JavaScript or (S)CSS "application" pages, that's because 
there's no other mechanism that a gem could use to auto-mount the paths there. 
The Bootstrap gem is essentially just providing packaging for the JS and CSS 
that is Bootstrap. That last few inches is you adding it to your application in 
a thoughtful way, just as you would any other JS or (S)CSS file. 

If there were an "automatic" way to add it, it would probably be like the CSS ` 
*= require_tree .` construct, which works alphabetically. That would ignore any 
overrides you wanted to set, or in the case of SCSS, any variables you wanted 
to populate with values. Doing things the long-hand way gives you a chance to 
ensure that requirements are met and there's a predictable order to loading. 
The same sort of thing would be even more critical in JS, where alphabetical 
order might load a jQuery plugin before jQuery itself.

Walter

> On Sep 20, 2019, at 8:42 AM, fugee ohu  wrote:
> 
> ?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/24df8def-a4da-4459-bdfa-f1b4d3a02812%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/D99660F1-8F1D-4B21-883B-14DD382A670E%40wdstudio.com.


Re: [Rails] Carrierwave multiple file uploads

2019-09-15 Thread Walter Lee Davis
My understanding is that the helpers do the "80%" solution for you -- pave the 
cowpaths -- but expect you to do the edge cases yourself, since you know what 
you are doing and what you want. Too much "magic" breeds a complacent user that 
expects everything to just work, all the time, which is unreasonable for the 
simple fact that software cannot read minds.

Walter

> On Sep 14, 2019, at 7:27 PM, Ariel Juodziukynas  wrote:
> 
> It adds the "[]" so the parameter is an array (if you don't add that, 
> params[:avatar] will be only one file and not an array). I'm not sure why but 
> the helper does not infer that, you have to be explicit on that.
> 
> El vie., 13 sept. 2019 a las 12:34, fugee ohu () escribió:
> I read this example for the form:
> <%= p.file_field :avatar, :multiple => true, name: 
> "post_attachments[avatar][]" %>
> Why is the name argument necessary Why can't the controller just get the 
> array from <%= p.file_field :avatar %> ?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/596e6ab8-a045-4bfc-86cb-252bf487f296%40googlegroups.com.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcC50WrnXZGt88HwMU_7obfY398X4guJ1uPqYDqAx%3DoCUQ%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/D24888D7-9D01-4FB3-81C6-7CFB0AFF6800%40wdstudio.com.


Re: [Rails] database maintenance, updating tables having has_many_through relationships

2019-09-14 Thread Walter Lee Davis
Is this something you'd like to maintain automatically, or just do once? You 
remember how to use the console (if the latter)? 

Picture.find_each do |pic|
  pic.update caption: pic.item.caption
end

If you want to do it every time you save a new picture, then you can add a 
similar helper to the Picture model, and call it in a before_save callback:

def cache_caption
  self.caption = item.caption
end

before_save :cache_caption

Walter

> On Sep 14, 2019, at 4:45 AM, fugee ohu  wrote:
> 
> I have a table of items and a table a pictures table They relate to each 
> other through an item_pictures table having model name item_picture All my 
> items have titles but I just added captions to my pictures table and now I 
> wanna update all the records in pictures to set the captions column to the 
> value of each picture's item's title 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/c5a41104-770c-48ba-abc9-450e4e1096f5%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/8113E780-69A3-4222-8AF7-2D7F30401CEB%40wdstudio.com.


Re: [Rails] Difficulty verifying site ownership for google search console

2019-08-31 Thread Walter Lee Davis
Yes, all else being correctly configured, files in your public folder should be 
available -- as long as you have the exact file name. A file in the /public 
folder would be available at your.site/file.name (don't put the 'public' part 
in the browser path).

There is a setting in your production.rb file that governs whether you allow 
your Web server to host these files, or if they are to be served through Rails. 
I don't recall what the default is. If you have it configured to go through 
your Web server, then NGINX or Apache configuration will govern how these files 
will be hosted. If you don't have that enabled, then it should Just Work.

One last thing to check is the ownership and permissions of your public folder 
and its contents. The folder should be world executable, and the files within 
it should be world readable. At a minimum, 557 for the folder and 644 for the 
files.

Walter

> On Aug 31, 2019, at 5:29 PM, fugee ohu  wrote:
> 
> I tried DNS TXT record google-site-verification but GSC (google search 
> console) says not found and says it did find an SRV record Yes the SRV 
> records are there  but so what 
> Then I tried with a different method, the URL Prefix method where they gave 
> me an html file to download and then I placed in my site's public folder but 
> then when I try to verify GSC says timed out and when I try to visit the link 
> in my browser it returns 403 If I place an html file in my public directory 
> shouldn't it be available to the world?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/c786e105-acf6-4f73-b4fa-f3c841d8c6c5%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/26EF611A-8D97-410A-B5A0-DE6E2DD69979%40wdstudio.com.


Re: [Rails] Rails and Machine Learning implementation of Python or Ruby

2019-08-17 Thread Walter Lee Davis
If you shell out to Python, you will have access to anything that Python has 
access to. I haven't used it in many years, so I don't know what that might be, 
but it would be the same as running your Python application raw in the native 
operating system, because that's what you're actually doing.

python your_program.py

vs

#! /usr/bin/env ruby

result = system 'python your_program.py'

There's really no difference from the point of view of the python program.

Walter

> On Aug 16, 2019, at 10:26 PM, Adrián Rama Aguilar 
>  wrote:
> 
> And it will be possible to use scientific libraries.??
> El viernes, 16 de agosto de 2019, 16:34:16 (UTC-4), Adrián Rama Aguilar  
> escribió:
> Hi everyone.!!
> 
> I'm working in a ROR app, which manages banks and I'd like to implement 
> machine learning for predictions such as ip connections, number of 
> transactions or number of sing in users by institucion in the app, so I've 
> been reading about linear regresion, but most of the info or how to do it is 
> with pyhton, so here comes my doubts to know if python modules can be 
> implemented or how to do this implementation in machine learnig in Ruby at a 
> ROR app. Thank you and I look forward to your contributions.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/e42afea2-b206-46b3-ad80-a6adb2744bdf%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/6CF36975-27D7-4D8B-BA4F-F2CEC35A53E1%40wdstudio.com.


Re: [Rails] Rails and Machine Learning implementation of Python or Ruby

2019-08-16 Thread Walter Lee Davis
Ruby will happily co-exist with python, if you want to "shell out" to that 
language, you can read the response back in and continue in Ruby. There are at 
least three ways to do this, from the humble back-tick ` operator to Open3 or 
the system call. And, hang on, there's Terrapin 
https://github.com/thoughtbot/terrapin to make this even safer.

Walter

> On Aug 16, 2019, at 11:53 AM, Adrián Rama Aguilar 
>  wrote:
> 
> Hi everyone.!!
> 
> I'm working in a ROR app, which manages banks and I'd like to implement 
> machine learning for predictions such as ip connections, number of 
> transactions or number of sing in users by institucion in the app, so I've 
> been reading about linear regresion, but most of the info or how to do it is 
> with pyhton, so here comes my doubts to know if python modules can be 
> implemented or how to do this implementation in machine learnig in Ruby at a 
> ROR app. Thank you and I look forward to your contributions.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/8a685786-e433-4fe4-b635-2387a7b3a15d%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/C178D978-7C2A-4749-A841-0A42131A0C53%40wdstudio.com.


Re: [Rails] How do I let nginx know I'm using rails?

2019-08-16 Thread Walter Lee Davis
Passenger is an application server that can either run as a plug-in to a web 
server, just like fastcgi or mod_php, or as a stand-alone server. When it runs 
as a stand-alone server, it actually uses an embedded copy of nginx as part of 
its code—but don’t let that confuse you. It’s still an application server, 
running as a separate process from the ‘http’ nginx server that is listening 
for requests from browsers. That ‘http’ server needs to be configured with a 
reverse proxy to the application server.

And an aside: Passenger is the best-documented, easiest to use application 
server I have ever used. I would not be so quick to run away from it. Figure 
out what your certbot issue is and fix that. You have a lot more work ahead of 
you to use a different approach. 

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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/0a33b4a4-c3a5-4f8d-ae54-77840cbfb589%40googlegroups.com.


Re: [Rails] How do I let nginx know I'm using rails?

2019-08-16 Thread Walter Lee Davis
NGINX on its own cannot "run" Rails, because it is a simple httpd server. Rails 
needs an application server -- puma, unicorn, passenger -- to be a bridge 
between http and Rack protocols. Rails is a Rack application, under all the 
layers, and cannot host anything all by itself. Don't be confused by the fact 
that passenger can run as an Apache or NGINX plugin. That's just an 
implementation detail. Passenger can run as a stand-alone application server, 
too.

The pattern is this: Application Server starts up, accepts connections at some 
port, like 12345. NGINX or Apache or whatever Web Server starts up, accepts 
connections at 80 or 443 or both. A "reverse proxy" is configured in the Web 
Server configuration, and when a request comes in that matches it, the request 
is proxied to the Application Server. The response from the Application Server 
is then proxied back through the Web Server to the requesting browser.

1. Figure out which Application Server you want to use to run your Rails 
application, and configure it to start at system start, and to restart when you 
need it to (every time you update your Rails code).
2. Google "how do I configure a reverse proxy in NGINX". Do what you see in the 
results.

That's how you set this up.

Walter

> On Aug 15, 2019, at 10:03 PM, fugee ohu  wrote:
> 
> 
> 
> On Thursday, August 15, 2019 at 2:51:44 PM UTC-4, Walter Lee Davis wrote:
> Set up a reverse proxy in nginx, pointed from port [80,443] to whatever port 
> your application server [puma, unicorn, webrick] is listening at. 
> 
> Walter 
> 
> > On Aug 15, 2019, at 2:43 PM, fugee ohu  wrote: 
> > 
> > How do I let nginx know I'm using rails when I'm not using passenger but 
> > instead system installed nginx standalone with rails apps 
> > 
> > -- 
> > 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 rubyonra...@googlegroups.com. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/rubyonrails-talk/1aff5f48-504a-426f-96c9-dadefea8025f%40googlegroups.com.
> >  
> 
> 
>  Not exactly the answer I was looking for If I'm using rails with nginx 
> system install, not the passenger nginx module, then how does the nginx 
> webserver know that I'm running RoR apps because the problem is that nginx is 
> looking for resource routes as subdirectories of /public
>  
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/7694b56e-5ae7-49a5-8068-0999acf7da64%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/B9495552-9480-4077-BE51-327DDA081F49%40wdstudio.com.


Re: [Rails] How do I let nginx know I'm using rails?

2019-08-15 Thread Walter Lee Davis
Set up a reverse proxy in nginx, pointed from port [80,443] to whatever port 
your application server [puma, unicorn, webrick] is listening at.

Walter

> On Aug 15, 2019, at 2:43 PM, fugee ohu  wrote:
> 
> How do I let nginx know I'm using rails when I'm not using passenger but 
> instead system installed nginx standalone with rails apps
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/1aff5f48-504a-426f-96c9-dadefea8025f%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/97FA756E-2A2C-412C-90F0-A3908381E568%40wdstudio.com.


Re: [Rails] ActiveStorage links are too long!

2019-08-11 Thread Walter Lee Davis
We're trying it out here, not sure if it will replace Shrine or not. It's 
optional, so you don't have to use it. But note that Paperclip was deprecated 
the moment that ActiveStorage was announced. "Bundled" is better than "add-on" 
for many people. https://shrinerb.com is really wonderful, and so well 
supported that I genuinely worry about the developer burning out.

One other thing that they may be doing with the lengthy URLs is "security 
through obscurity", so that the URLs are genuinely un-guessable. Not to say 
that a YouTube hash is any more guessable.

Walter

> On Aug 11, 2019, at 9:14 PM, Aleksandr Shelestov  wrote:
> 
> Thanks for reply Walter.
> 
> I'm not sure I need all this stuff and even I understand the purpose of it.
> 
> For unique UUID a simple hash is more than enough (Youtube stores billions of 
> unique videos using just 11 chars). And I'm even not saying about the 
> url-shortener services.
> SecureRandom lets us to create unique tokens almost for everything, using 24 
> characters (for example).
> 
> In my case users should be able to upload files into the editor, with no 
> relations with the editable Article, just it. It's a simple feature we all 
> need very often. Why other libraries don't generate so long links for this?
> 
> Also, I just found out, the long link is always a redirect to the App to get 
> a temporary link to a storage service, so it won't be cached by browsers, 
> ever. Jeez...
> 
> Looks like ActiveStorage is a unique tool for certain things in Basecamp, not 
> a Carrierwave substitute. Am I right?
> 
> On Monday, August 12, 2019 at 2:39:21 AM UTC+3, Walter Lee Davis wrote:
> I'm not an author of this gem, but at a guess, I would say that the lengthy 
> URLs are there to ensure that there is no chance of two people uploading a 
> same-name file and getting a collision. Those look a lot like UUIDs, which 
> are often used for this purpose. Remember, when you drag something into the 
> editor, the parent record has not been saved, and so you could not do 
> anything clever like add the parent record ID to the URL so it could be used 
> for disambiguation. 
> 
> Walter 
> 
> > On Aug 11, 2019, at 4:36 PM, Aleksandr Shelestov  wrote: 
> > 
> > A question to the creators of ActiveStorage. 
> > 
> > I just implemented the upload feature to my own editor (nothing special, 
> > something similar to Github Text Editor). After the user dropped the file 
> > to the textarea the uploading process starts and puts a returned link back 
> > to the editor: 
> > 
> > <62838761-06ac3000-bc89-11e9-98ea-cf4a428d6c4b.png> 
> > 
> > The questions is — why the hell the links are so long?! What's the point? 
> > 
> > First, there is a limited amount of chars in the editor. Second, it just 
> > looks ugly. And if I add ten pictures in a row it's getting even much 
> > uglier. 
> > 
> > Why is it not something like this: 
> > 
> > 
> > ![2019-05-28 10.37.34.jpg](/r/a_s/b/eyJfcmFpbHMiO.jpg) 
> > ? 
> > 
> > 
> > Maybe I missed something and there is a way to get back a shorter version? 
> > 
> > 
> > -- 
> > 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 rubyonra...@googlegroups.com. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/rubyonrails-talk/b9748bd4-9edb-4475-8f25-a811497cf4fc%40googlegroups.com.
> >  
> > <62838761-06ac3000-bc89-11e9-98ea-cf4a428d6c4b.png> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/0a5076a3-44cb-4e1e-9063-0e68378aca0e%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/9A27488F-336A-4EA0-800F-B3F0AF0E2248%40wdstudio.com.


Re: [Rails] ActiveStorage links are too long!

2019-08-11 Thread Walter Lee Davis
I'm not an author of this gem, but at a guess, I would say that the lengthy 
URLs are there to ensure that there is no chance of two people uploading a 
same-name file and getting a collision. Those look a lot like UUIDs, which are 
often used for this purpose. Remember, when you drag something into the editor, 
the parent record has not been saved, and so you could not do anything clever 
like add the parent record ID to the URL so it could be used for disambiguation.

Walter

> On Aug 11, 2019, at 4:36 PM, Aleksandr Shelestov  wrote:
> 
> A question to the creators of ActiveStorage.
> 
> I just implemented the upload feature to my own editor (nothing special, 
> something similar to Github Text Editor). After the user dropped the file to 
> the textarea the uploading process starts and puts a returned link back to 
> the editor:
> 
> <62838761-06ac3000-bc89-11e9-98ea-cf4a428d6c4b.png>
> 
> The questions is — why the hell the links are so long?! What's the point?
> 
> First, there is a limited amount of chars in the editor. Second, it just 
> looks ugly. And if I add ten pictures in a row it's getting even much uglier.
> 
> Why is it not something like this:
> 
> 
> ![2019-05-28 10.37.34.jpg](/r/a_s/b/eyJfcmFpbHMiO.jpg)
> ?
> 
> 
> Maybe I missed something and there is a way to get back a shorter version?
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/b9748bd4-9edb-4475-8f25-a811497cf4fc%40googlegroups.com.
> <62838761-06ac3000-bc89-11e9-98ea-cf4a428d6c4b.png>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/6D94E210-6944-4408-B898-4C30680728C8%40wdstudio.com.


Re: [Rails] Basics: How does Javascript communicate with Ruby on Rails?

2019-08-08 Thread Walter Lee Davis
Well, in my particular case, I already understood the way that the controller 
accepts the incoming request and assigns the attributes. That understanding 
came from many many years of working in Rails. 

The save part I understood intuitively, because years ago, I wrote an 
implementation of Active Record (the pattern: 
https://en.wikipedia.org/wiki/Active_record_pattern) in PHP. So I knew 
approximately where to look, and googled 'active record base save'. 

That took me to a disambiguation page on APIdock, where I found out that the 
method had moved around a few times. I knew that the concept of saving 
something to the database is known in Rails as "persistence" (a model instance 
has the method `persisted?` on it, for example), so I picked the version of 
#save that was in the persistence module, and followed the source. Each listing 
in APIdock has the snippet of source code that implements that method, and each 
method in turn contained more sub-methods that further processed the request to 
save. I followed the trail down one path only (I didn't bother showing all the 
details of what happens when you try to save something that is already 
persisted, which makes an UPDATE query rather than an INSERT query).

I've been following Rails as a technology since it was publicly announced, back 
in 2005 or so. I tried it briefly at that time, found it "too hard" for a 
struggling PHP hacker, and put it aside for a long time. I discovered a solid 
implementation of the ActiveRecord pattern in PHP, and used it successfully for 
several years in my commercial work. When the developer abandoned it, I took 
over the project and further refined it.

When PHP 5.3 made that library stop working, I wrote a clean-room replacement 
that followed the newer rules of PHP's classes. After using that for a couple 
more years, and looking at a several fairly mature Rails clones in PHP, I 
finally decided to stop trying to use copies and go to the original. My skills 
had leveled up, and Rails' tooling had improved, to the point that we were now 
compatible.

I made a "bet" with myself that I would just use Rails for the next project 
that came through my door. This was a request for a document repository with 
multiple levels of authorization (some people could author, some people could 
approve, some people could read-only). This was a great fit for Rails and its 
constellation of RubyGems. At the end of that project, I ran `rake stats` on 
the project. I found that I had written ~170 lines of code, ~250 lines of 
tests, and everything else came from a Gem or the framework itself. For those 
lines of code, I was paid $17K. That was enough of a reason to dive in and 
never look back.

Walter

> On Aug 7, 2019, at 10:15 PM, Noel  wrote:
> 
> You just hit everything that I was trying to figure out and then some. This 
> is what I’ve been needing to know(I can’t be certain of the that). Last 
> question, how did you figure that out?; because that’s where this is kind of 
> embarrassing, that I’ve held out to ask this for so long for fear. I’m sure 
> intuition and experience comes with understanding what’s under the hood, but 
> how does a junior dev figure stuff out like this? Please be merciful, don’t 
> say look at the documentation, the documentation needs documentation. The 
> documentation is not very clear for a junior dev because some stuff is 
> abstracted and it’s like you have to be in the know about some other 
> concept(that is omitted because reasons) that isn’t mentioned but understood.
> 
> Goes without saying but thanks man, this is solid knowledge I can use. 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/cec8887e-7b38-4feb-b403-ef2810038a84%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/3255E199-52BE-4B4E-91ED-0360032083CC%40wdstudio.com.


Re: [Rails] Basics: How does Javascript communicate with Ruby on Rails?

2019-08-07 Thread Walter Lee Davis
Here's an incoming form submission:

Started POST "/coupons" for ::1 at 2019-08-07 20:52:23 -0400
Processing by CouponsController#create as HTML
  Parameters: {"utf8"=>"✓", 
"authenticity_token"=>"xyBXVRs1DfQlkDxXlG/iTmxDMChOsPVfcgbNGX8dNOi5uPwfyBluAXcPFssxf5IQLPyoP2VWSPVjzZKeudwrHA==",
 "coupon"=>{"code"=>"TESTING", "discount_percent"=>"30", "discount_amount"=>"", 
"free_shipping"=>"0", "never_expires"=>"1", "uses_until_expiration"=>"", 
"user_email"=>"", "book_number"=>"", "category"=>"", "collection"=>"", 
"description"=>""}, "commit"=>"Create Coupon"}

It hits the controller, where the params are run through the strong parameters 
(whitelist) and assigned to the object (instance of the model):

def coupon_params
  params.require(:coupon).permit(:code, :discount_percent, 
:discount_amount, :expires_on,
:never_expires, :uses_until_expiration, :redemptions, :user_email, 
:book_number, :description, :free_shipping,
:collection, :category)
end

  def create
@coupon = Coupon.new(coupon_params)
respond_to do |format|
  if @coupon.save
format.html { redirect_to @coupon, notice: "Coupon was successfully 
created." }
format.json { render :show, status: :created, location: @coupon }
  else
format.html { render :new }
format.json { render json: @coupon.errors, status: 
:unprocessable_entity }
  end
end
  end

When you call save or update on the instance, the instance is persisted to the 
database. The actual implementation of this happens in the superclass of 
ActiveRecord::Base that all of your models descend from. 

# File activerecord/lib/active_record/persistence.rb, line 274
def save(*args, )  
  create_or_update(*args, )
rescue ActiveRecord::RecordInvalid
  false
end

This in turn calls create_or_update

# File activerecord/lib/active_record/persistence.rb, line 702
def create_or_update(*args, )  
  _raise_readonly_record_error if readonly?  
  return false if destroyed?  
  result = new_record? ? _create_record() : _update_record(*args, ) 
 
  result != false
end

You can keep on digging all the way down through a bunch more layers of 
indirection, but in the end, you get to the money:

# File activerecord/lib/active_record/persistence.rb, line 168  
def _insert_record(values) # :nodoc:
  primary_key_value = nil

  if primary_key && Hash === values  
primary_key_value = values[primary_key]

if !primary_key_value && prefetch_primary_key?
  primary_key_value = next_sequence_value
  values[primary_key] = primary_key_value  
end
  end

  if values.empty?  
im = arel_table.compile_insert(connection.empty_insert_statement_value) 
 
im.into arel_table
  else  
im = arel_table.compile_insert(_substitute_values(values))
  end

  connection.insert(im, "#{self} Create", primary_key || false, 
primary_key_value)  
end

That's where you can see the Arel layer coming into play. `connection` is an 
instance of the connection adapter you configured, depending on which database 
you're using. When you call connection.insert, the `im` is passed to it, and 
that's an instance of the Arel AST representing the insert statement, filled in 
with the values assigned to the model instance.

Back to my live example above, here's the SQL that it got turned into (for 
MySQL):

  Coupon Create (0.9ms)  INSERT INTO `coupons` (`code`, `discount_percent`, 
`user_email`, `created_at`, `updated_at`, `description`, `collection`, 
`category`) VALUES ('TESTING', 30, '', '2019-08-08 00:52:23', '2019-08-08 
00:52:23', '', '', '')
  ↳ app/controllers/coupons_controller.rb:32

Hope this little tour helps you better understand the "magic" happening in 
ActiveRecord and Rails.

Walter

> On Aug 7, 2019, at 11:53 AM, Noel  wrote:
> 
> Genuinely, I thank both of you for your insights. Without stretching this 
> thread out any more, I want to figure out one last concept. 
> 
> Form data, based on what was mentioned above, is it that the headers dictate 
> what is passed on as data to be persisted? Like where in the chain of events 
> does the SQL know that this is the data to be persisted? I think that’s where 
> I get foggy, I understand the concepts of the http request/response but at 
> what point is the data from a form understood or decided or interpreted by 
> SQL? That’s all in the adapter?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/03b39e95-71af-4e6e-9f14-78047c70f74e%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on 

Re: [Rails] Basics: How does Javascript communicate with Ruby on Rails?

2019-08-07 Thread Walter Lee Davis
On the JS side, the JavaScript application (or simple inline script, no 
difference) makes an HTTP request to or from the server, and the server (Rails) 
responds to that request, just as it would any other request. The Rails 
framework uses the "accept" headers sent as part of that request to determine 
what sort of response to send (JSON, inline JS, HTML, text, whatever else) and 
that's the long and short of that.

As far as databases go, ActiveRecord (the library, not the pattern) has 
connection adapters for each of the major database engines, and there are 
others you can plug in, say for Oracle or MS SQL Server, if you're not using 
Postgres or MySQL or similar. That's all handled at the gem + configuration 
level. Once you have plugged in the adapter for your specific engine, the 
actual communication between Rails (well more accurately, ActiveRecord) and the 
database engine is quite clever. 

Ruby code like:
  class Foo < ApplicationRecord
has_many :bars
  end
  class Bar < ApplicationRecord
belongs_to :foo
  end
  f = Foo.new
  f.bars << Bar.first
  f.save

...is first converted into an Arel AST (abstract syntax tree) that is 
database-independent, and then the database adapter is responsible for 
converting that AST into actual SQL for the specific database engine and 
sending and retrieving and interpreting data from the server. (Despite SQL 
being an ISO standard, no two implementations are identical.) 

The upshot of this is that you can have (as I do at work) your tests running 
against SQLite, and your production server running Oracle 12. And your tests 
work and predict the results from your production server.

You can learn more about this at the Rails Guides https://guides.rubyonrails.org

Walter

> On Aug 7, 2019, at 12:20 AM, Noel  wrote:
> 
> Hello to All,
>  I'm trying to understand something that I seem to get lost on, which is 
> how exactly does Javascript communicate with Rails? I understand how to make 
> it work, I can even make a React front-end and Rails API work together. But I 
> feel like I am missing something fundamental when it comes to how this 
> communication actually occurs. If you know if a resource that explains this, 
> I would be grateful.
> 
> Also, how does SQL communicate with Ruby or viceversa? A good resource that 
> breaks it down would be great.
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/dffe00e4-61d1-46a4-8123-34d631a6148b%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/EC75674A-CC23-4629-B6F5-5E089DF5E511%40wdstudio.com.


Re: [Rails] Drag and Drop question

2019-07-21 Thread Walter Lee Davis
You'll have to assign the values you get back (in JavaScript) to a 
properly-named form element in your form. Try making a hidden input in the form 
with the name set to meal[meal_item_ids]. Then locate that field in JavaScript 
in your callback function (which fires after the drop event) and set the value 
of that hidden field to the array of values you get in your callback. 

Walter 

> On Jul 20, 2019, at 9:24 PM, John Sanderbeck  wrote:
> 
> I understand that part Walter.  I have done many nested forms. However, this 
> is the first one with a drag and drop feature.
> 
> The part I am struggling with is how to populate the array that gets passed 
> back through the drag and drop events.
> 
> I have the strong params setup and could easily just add a simple nested 
> form, but I wanted to add the drag and drop as a feature so they could build 
> the meals easily with an IPad.
> 
> John
> 
> On Saturday, July 20, 2019 at 8:59:21 PM UTC-4, Walter Lee Davis wrote:
> I'm not sure how your form is constructed at the moment. But if you were 
> passing the result of the dragged items back to a meals_controller, you could 
> assign the array of values to `menu_item_ids` and the child menu items would 
> be created and assigned. You'll have to ensure that you whitelist that 
> attribute in a special way: 
> 
> def meal_params 
>   params.permit(:foo, :bar, :baz, menu_item_ids: []) 
> end 
> 
> You'll want to put this (and any other array-shaped parameters) at the end of 
> the list of permitted params, and you have to cast it to an array as I've 
> done here. 
> 
> If you are sending the form to the menus_controller, then you've got a 
> doubly-nested assignment going on, and you'll probably want to use 
> accepts_nested_parameters_for in your model relationship between menu and 
> meal. I would do that if I was building N number of meals within one menu 
> form. If you're trying to get this going first, I would just save each meal 
> individually first, and then, once it's working at that level, try to further 
> complicate it by nesting forms. 
> 
> Walter 
> 
> > On Jul 20, 2019, at 12:25 PM, John Sanderbeck  wrote: 
> > 
> > Ok. Changed to Document.ready and got the drag and drops firing...   
> > 
> > Also changed the data URl to be a data ID which is the ID of the meal item. 
> > 
> > The part I am unsure of is assigning the mitem array that gets passed back 
> > in the form... 
> > 
> > I know this should be simple and as you can tell I am a total newbie with 
> > this...  :-) 
> > 
> > John 
> > 
> > On Friday, July 19, 2019 at 10:48:56 AM UTC-4, John Sanderbeck wrote: 
> > I have an app in production that I am adding a module to for Lunch Ordering 
> > 
> > What I have is a Menu, which has Meals, and the Meals have Meal Items in 
> > Categories like Entree, Vegetable, Fruit, and Drink 
> > 
> > What I would like to do it allow Drag and Drop to build meals, and Drag and 
> > Drop to build Menus 
> > 
> > I made a standard Rails form with a Drag and Drop area for the meal with 
> > the items as draggable and sorted in groups on the right 
> > 
> > I don't think I need an Ajax call as I am building or editing the meal. 
> > What I need to be able to do is manipulate the array that gets passed back 
> > for the Meal Items... 
> > 
> > Any suggestions or links I can look at to do this? 
> > 
> > John Sanderbeck 
> > 
> > 
> > 
> > 
> > 
> > -- 
> > 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 rubyonra...@googlegroups.com. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/rubyonrails-talk/f0ec2c68-3c7d-40db-85f4-52ff4ab3866c%40googlegroups.com.
> >  
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/faf99154-a737-4d91-a7e9-95b973e7ed69%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/A020658F-511F-4B21-BB23-AE3AA9F2C0F0%40wdstudio.com.


Re: [Rails] Drag and Drop question

2019-07-20 Thread Walter Lee Davis
I'm not sure how your form is constructed at the moment. But if you were 
passing the result of the dragged items back to a meals_controller, you could 
assign the array of values to `menu_item_ids` and the child menu items would be 
created and assigned. You'll have to ensure that you whitelist that attribute 
in a special way:

def meal_params
  params.permit(:foo, :bar, :baz, menu_item_ids: [])
end

You'll want to put this (and any other array-shaped parameters) at the end of 
the list of permitted params, and you have to cast it to an array as I've done 
here.

If you are sending the form to the menus_controller, then you've got a 
doubly-nested assignment going on, and you'll probably want to use 
accepts_nested_parameters_for in your model relationship between menu and meal. 
I would do that if I was building N number of meals within one menu form. If 
you're trying to get this going first, I would just save each meal individually 
first, and then, once it's working at that level, try to further complicate it 
by nesting forms.

Walter

> On Jul 20, 2019, at 12:25 PM, John Sanderbeck  wrote:
> 
> Ok. Changed to Document.ready and got the drag and drops firing...   
> 
> Also changed the data URl to be a data ID which is the ID of the meal item.
> 
> The part I am unsure of is assigning the mitem array that gets passed back in 
> the form...
> 
> I know this should be simple and as you can tell I am a total newbie with 
> this...  :-)
> 
> John
> 
> On Friday, July 19, 2019 at 10:48:56 AM UTC-4, John Sanderbeck wrote:
> I have an app in production that I am adding a module to for Lunch Ordering
> 
> What I have is a Menu, which has Meals, and the Meals have Meal Items in 
> Categories like Entree, Vegetable, Fruit, and Drink
> 
> What I would like to do it allow Drag and Drop to build meals, and Drag and 
> Drop to build Menus
> 
> I made a standard Rails form with a Drag and Drop area for the meal with the 
> items as draggable and sorted in groups on the right
> 
> I don't think I need an Ajax call as I am building or editing the meal. What 
> I need to be able to do is manipulate the array that gets passed back for the 
> Meal Items...
> 
> Any suggestions or links I can look at to do this?
> 
> John Sanderbeck
> 
> 
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/f0ec2c68-3c7d-40db-85f4-52ff4ab3866c%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/572E6A7A-B9F0-4EF2-9E38-D279ADE158E0%40wdstudio.com.


Re: [Rails] Drag and Drop question

2019-07-19 Thread Walter Lee Davis
What happens now when you drop the element? Do you see anything in your 
browser's JavaScript console indicating that the drop event fired? Did you do 
anything beyond CSS (to make it look a particular way) to define the draggable 
and droppable behaviors for these elements? Do the draggable elements have 
unique IDs or data-attributes or some other sort of identification scheme?

Here's where I would start looking for more information: 
https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API

Walter

> On Jul 19, 2019, at 10:48 AM, John Sanderbeck  wrote:
> 
> I have an app in production that I am adding a module to for Lunch Ordering
> 
> What I have is a Menu, which has Meals, and the Meals have Meal Items in 
> Categories like Entree, Vegetable, Fruit, and Drink
> 
> What I would like to do it allow Drag and Drop to build meals, and Drag and 
> Drop to build Menus
> 
> I made a standard Rails form with a Drag and Drop area for the meal with the 
> items as draggable and sorted in groups on the right
> 
> I don't think I need an Ajax call as I am building or editing the meal. What 
> I need to be able to do is manipulate the array that gets passed back for the 
> Meal Items...
> 
> Any suggestions or links I can look at to do this?
> 
> John Sanderbeck
> 
> 
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/f72ba618-4da8-4e4b-a261-5d39b233bc80%40googlegroups.com.
> 

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/8F137EF5-6122-4967-B59B-12632C62FD5D%40wdstudio.com.


Re: [Rails] New Business Unit/Team Cannot See Assigned Accounts/Records

2019-07-05 Thread Walter Lee Davis
I'm not sure what this has to do with Ruby on Rails. As far as I can tell, 
Dynamics 365 is a Microsoft accounting application. Rails is an open-source 
framework for building Web applications. The only place their circles cross is 
that you could probably build a similar application as Dynamics 365 with Rails.

Walter

> On Jul 5, 2019, at 7:09 AM, vijay kumar  wrote:
> 
> Hello!
> 
> I recently inherited a Dynamics 365 environment and am new to the system.  
> I'm working on a new requirement to only allow certain users to view certain 
> accounts.  IE:
> 
> Person A can only see account A
> Person B can only see account B
> 
> This environment has a single business unit accessing a custom entity.  After 
> doing research, I've made the following changes:
> 
> Created a new Business Unit as a child of the original
> Assigned user A to the new business unit
> Created and set user A with a single security role that only has Business 
> Unit access the custom entity
> Assigned account A to this new business unit's default team
> Unfortunately, all views for this user are showing as empty.  Here are some 
> tests I've run to try and resolve the issue:
> 
> Set all of the teams to have no security roles to avoid any permission 
> crossover. 
> Tried making a team outside of the default BU team with the same results 
> Tried to individually assign a record to user A, which also does not show up 
> in any view.  Not sure why any records fail to show for this user.
> Set the security role for the user to global on the entity in question and 
> that, of course, shows everything.  Anything less than global will not 
> display any records for this user no matter where they are. 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/12275cab-b693-4164-b6c7-94e3866acd05%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/B9524206-E921-4D5E-8CAC-8C7F4E5B0D85%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Querying Multi Database Tables and displaying in index.html.erb

2019-06-26 Thread Walter Lee Davis
Assuming you had a states_controller.rb that had a show method in it that 
looked something like this:

def show
  @state = State.find params[:id]
  render partial: 'cities_picker', layout: false
end

you could have a views/states/_cities_picker.html.erb that looked like this:

<%= select_tag('address[city_id]', 
options_from_collection_for_select(@state.cities, :id, :name)) %>

That's all you would need to make a fully populated picker with 


  Aliquippa
  Allentown
  ...
  York<.option>


That's assuming you have the data set up and populated so you know that these 
are the cities in Pennsylvania. You'd possibly put a label or some other HTML 
in there, but if you were swapping out this form element for one populated with 
the cities of Ohio, then you'd probably what to move as little around as 
necessary, and just leave the label and any structural HTML untouched in the 
parent page.

Walter

> On Jun 25, 2019, at 11:18 PM, David Merrick  wrote:
> 
> HI What would the  render partial: 'cities_picker', layout: false look like 
> in your example?
> 
> On Fri, May 31, 2019 at 2:25 PM Walter Lee Davis  wrote:
> What do the pickers mean? What values are they representing? When you choose 
> one picker value, why does another picker need a different set of values to 
> appear? If you can explain how you have modeled that part of your data, then 
> I can help you further. In principle, a controller (any controller) can 
> handle requests related to any model. It's just a convention that if you have 
> a model Foo, you will have a FoosController to handle requests related to 
> that model. 
> 
> Here's a practical example of how you might use this sort of cascading picker:
> 
> class Country < ApplicationRecord
>   has_many :states
> end
> 
> class State < ApplicationRecord
>   belongs_to :country
>   has_many :cities
> end
> 
> class City < ApplicationRecord
>   belongs_to :state
> end
> 
> You have a natural cascade of country to state to city, and it makes sense 
> what those relationships are. The relationships are codified with the 
> has_many and belongs_to macros, so it's clear that if you say @state.cities, 
> you will get the cities that exist inside that state. You would do that by 
> establishing what the parent id is in each child record. You might have 
> Arizona as @state id = 1, and then have a bunch of cities like Phoenix: @city 
> id = 22, state_id = 1, so you can gather them up.
> 
> So you have choices now as to choosing a controller pattern. The REST design 
> says that you should have a separate controller for each model, and so that 
> could go like this:
> 
> class CountriesController < ApplicationController
>   def index
> @countries = Country.order(:name)
> render partial: 'countries_picker', layout: false
>   end
> 
>   def show
> country = Country.find params[:id]
> @states = @country.states.order(:name)
> render partial: 'states_picker', layout: false
>   end
> end
> 
> class StatesController < ApplicationController
>   def show
> state = State.find params[:id]
> @cities = @state.cities.order(:name)
> render partial: 'cities_picker', layout: false
>   end
> end
> 
> Your routes would look like this
> 
> resources :countries, only: [:index, :show]
> resources :states, only: :show
> 
> If you wanted to have a single controller concerned with making these pickers 
> (and ignore the whole REST thing), then you could have:
> 
> class PickersController < ApplicationController
>   def countries
> @countries = Country.order(:name)
> render partial: 'countries_picker', layout: false
>   end
> 
>   def states
> country = Country.find params[:id]
> @states = country.states.order(:name)
> render partial: 'states_picker', layout: false
>   end
> 
>   def cities
> state = State.find params[:id]
> @cities = state.cities.order(:name)
> render partial: 'cities_picker', layout: false
>   end
> end
> 
> Your routes could look like this:
> 
> match '/countries', to: 'pickers#countries', via: :get, as: :countries_picker
> match '/states', to: 'pickers#states', via: :get, as: :states_picker
> match '/cities', to: 'pickers#cities', via: :get, as: :cities_picker
> 
> See -- there's no rules that say that you have to use one controller for one 
> model, or have a separate controller for each model. Mix and match. Have fun! 
> Rails is flexible.
> 
> Walter
> 
> > On May 30, 2019, at 6:56 PM, David Merrick  wrote:
> > 
> > Hi If this is my last table I want to use
> > 
> > create_table "points", force: :cascade do |t|
> > t.text "place"
> >

Re: [Rails] Querying Multi Database Tables and displaying in index.html.erb

2019-05-30 Thread Walter Lee Davis
What do the pickers mean? What values are they representing? When you choose 
one picker value, why does another picker need a different set of values to 
appear? If you can explain how you have modeled that part of your data, then I 
can help you further. In principle, a controller (any controller) can handle 
requests related to any model. It's just a convention that if you have a model 
Foo, you will have a FoosController to handle requests related to that model. 

Here's a practical example of how you might use this sort of cascading picker:

class Country < ApplicationRecord
  has_many :states
end

class State < ApplicationRecord
  belongs_to :country
  has_many :cities
end

class City < ApplicationRecord
  belongs_to :state
end

You have a natural cascade of country to state to city, and it makes sense what 
those relationships are. The relationships are codified with the has_many and 
belongs_to macros, so it's clear that if you say @state.cities, you will get 
the cities that exist inside that state. You would do that by establishing what 
the parent id is in each child record. You might have Arizona as @state id = 1, 
and then have a bunch of cities like Phoenix: @city id = 22, state_id = 1, so 
you can gather them up.

So you have choices now as to choosing a controller pattern. The REST design 
says that you should have a separate controller for each model, and so that 
could go like this:

class CountriesController < ApplicationController
  def index
@countries = Country.order(:name)
render partial: 'countries_picker', layout: false
  end

  def show
country = Country.find params[:id]
@states = @country.states.order(:name)
render partial: 'states_picker', layout: false
  end
end

class StatesController < ApplicationController
  def show
state = State.find params[:id]
@cities = @state.cities.order(:name)
render partial: 'cities_picker', layout: false
  end
end

Your routes would look like this

resources :countries, only: [:index, :show]
resources :states, only: :show

If you wanted to have a single controller concerned with making these pickers 
(and ignore the whole REST thing), then you could have:

class PickersController < ApplicationController
  def countries
@countries = Country.order(:name)
render partial: 'countries_picker', layout: false
  end

  def states
country = Country.find params[:id]
@states = country.states.order(:name)
render partial: 'states_picker', layout: false
  end

  def cities
state = State.find params[:id]
@cities = state.cities.order(:name)
render partial: 'cities_picker', layout: false
  end
end

Your routes could look like this:

match '/countries', to: 'pickers#countries', via: :get, as: :countries_picker
match '/states', to: 'pickers#states', via: :get, as: :states_picker
match '/cities', to: 'pickers#cities', via: :get, as: :cities_picker

See -- there's no rules that say that you have to use one controller for one 
model, or have a separate controller for each model. Mix and match. Have fun! 
Rails is flexible.

Walter

> On May 30, 2019, at 6:56 PM, David Merrick  wrote:
> 
> Hi If this is my last table I want to use
> 
> create_table "points", force: :cascade do |t|
> t.text "place"
> t.text "riders"
> t.integer "racepoints"
> t.text "status"
> t.integer "race_id"
> t.datetime "created_at", null: false
> t.datetime "updated_at", null: false
> t.index ["race_id"], name: "index_points_on_race_id"
>   end
> 
> Which references the other tables.  Are you saying I could just use this 
> table or do I still need the Pickers controller?
> 
> Cheers Dave
> 
> On Fri, May 31, 2019 at 1:23 AM Walter Lee Davis  wrote:
> Yes, that's how you would get the pickers controller, if that's how you want 
> to model this. You could also use your existing controller for the object in 
> question (I've forgotten the names of things in your original app). If you 
> had a widgets_controller, you could make a method in that for each of your 
> pickers. Your route would change depending on which approach you chose. To 
> add the route, you would open your routes file and add the appropriate 
> declaration there:
> 
> (assuming you were using pickers_controller#picker_two)
> 
> resources :pickers, only: [] do
>   collection do
> get :picker_two, to: 'pickers#picker_two'
> get :picker_three, to: 'pickers#picker_three'
>   end
> end
> 
> (If you already had a widgets_controller, and wanted to add on)
> 
> resources :widgets do
>   collection do
> get :picker_two, to: 'widgets#picker_two'
> get :picker_three, to: 'widgets#picker_three'
>   end
> end
> 
> Then run 'rake routes' to see what those routes get named. Note 

Re: [Rails] Querying Multi Database Tables and displaying in index.html.erb

2019-05-30 Thread Walter Lee Davis
Yes, that's how you would get the pickers controller, if that's how you want to 
model this. You could also use your existing controller for the object in 
question (I've forgotten the names of things in your original app). If you had 
a widgets_controller, you could make a method in that for each of your pickers. 
Your route would change depending on which approach you chose. To add the 
route, you would open your routes file and add the appropriate declaration 
there:

(assuming you were using pickers_controller#picker_two)

resources :pickers, only: [] do
  collection do
get :picker_two, to: 'pickers#picker_two'
get :picker_three, to: 'pickers#picker_three'
  end
end

(If you already had a widgets_controller, and wanted to add on)

resources :widgets do
  collection do
get :picker_two, to: 'widgets#picker_two'
get :picker_three, to: 'widgets#picker_three'
  end
end

Then run 'rake routes' to see what those routes get named. Note that because 
these are "collection" routes, they won't pass the ID as I had noted in my 
example previously. You'd have to pass that as a querystring variable, so your 
link would be something like /widgets/picker_two?parent=42, and you'd have to 
allow the parent argument in your safe_params, and then get it with 
params[:parent] rather than relying on the id.

Most flexible of all would be to use match rather than a resource-based route:

match 'picker_two/:id', to: 'pickers#picker_two', via: :get, as: :picker_two

That would get you a very specific named route that would fit with my original 
example.

All of this is covered in great detail in the excellent guide "Routing from the 
outside in", at guides.rubyonrails.org

The ultimate answer to your questions is 'you use the framework'. All the tools 
are there for you to build whatever you want, or whatever makes sense to you.

Walter

> On May 30, 2019, at 12:15 AM, David Merrick  wrote:
> 
> Hi Can I just do rails g controller Pickers?
> 
> How do I get the route for this as not one is made?
> 
> Cheers Dave
> 
> On Wed, May 29, 2019 at 12:57 AM Walter Lee Davis  wrote:
> The way I start doing this is to decompose the view into partials, at least 
> one per picker. Make sure that each partial after the first one takes an 
> argument (allowed to be null) indicating what the previous picker chose. If 
> there is no argument passed, the picker is rendered with no options. Next, 
> you need to add controller, with a route per picker, and either write 
> unobtrusive JS event listeners, or add long-hand onchange arguments to your 
> picker to trigger the next picker.
> 
> f.collection_select :picker_one, @picker_one_options, :name, :id
> 
> $(document).on('change', '#picker_one', function(evt){
>   $('#picker_two_holder').load('/pickers/picker_two/' + $(this).val());
> });
> 
> In the pickers_controller, you'd have a method like 
> 
> def picker_two
>   @picker_two_options = Option.find(params[:id]).children
>   render partial: 'picker_two', layout: false
> end
> 
> Each picker then loads the next one, and finally, the surrounding form is 
> submitted with all the dynamic pickers within it. 
> 
> Let me know if any of this is too cryptic. 
> 
> Walter
> 
> > On May 28, 2019, at 4:06 AM, David Merrick  wrote:
> > 
> > My Schema.rb is below
> > 
> > ActiveRecord::Schema.define(version: 2019_05_27_040649) do
> > 
> >   create_table "days", force: :cascade do |t|
> > t.integer "season_id"
> > t.datetime "created_at", null: false
> > t.datetime "updated_at", null: false
> > t.date "raceday"
> > t.index ["season_id"], name: "index_days_on_season_id"
> >   end
> > 
> >   create_table "points", force: :cascade do |t|
> > t.text "place"
> > t.text "riders"
> > t.integer "racepoints"
> > t.text "status"
> > t.integer "race_id"
> > t.datetime "created_at", null: false
> > t.datetime "updated_at", null: false
> > t.index ["race_id"], name: "index_points_on_race_id"
> >   end
> > 
> >   create_table "races", force: :cascade do |t|
> > t.boolean "display"
> > t.text "racename"
> > t.integer "season_id"
> > t.integer "day_id"
> > t.datetime "created_at", null: false
> > t.datetime "updated_at", null: false
> > t.text "raceclass"
> > t.index ["day_id"], name: "index_races_on_day_id"
> > t.index ["season_id"], name: "index_

Re: [Rails] Querying Multi Database Tables and displaying in index.html.erb

2019-05-28 Thread Walter Lee Davis
The way I start doing this is to decompose the view into partials, at least one 
per picker. Make sure that each partial after the first one takes an argument 
(allowed to be null) indicating what the previous picker chose. If there is no 
argument passed, the picker is rendered with no options. Next, you need to add 
controller, with a route per picker, and either write unobtrusive JS event 
listeners, or add long-hand onchange arguments to your picker to trigger the 
next picker.

f.collection_select :picker_one, @picker_one_options, :name, :id

$(document).on('change', '#picker_one', function(evt){
  $('#picker_two_holder').load('/pickers/picker_two/' + $(this).val());
});

In the pickers_controller, you'd have a method like 

def picker_two
  @picker_two_options = Option.find(params[:id]).children
  render partial: 'picker_two', layout: false
end

Each picker then loads the next one, and finally, the surrounding form is 
submitted with all the dynamic pickers within it. 

Let me know if any of this is too cryptic. 

Walter

> On May 28, 2019, at 4:06 AM, David Merrick  wrote:
> 
> My Schema.rb is below
> 
> ActiveRecord::Schema.define(version: 2019_05_27_040649) do
> 
>   create_table "days", force: :cascade do |t|
> t.integer "season_id"
> t.datetime "created_at", null: false
> t.datetime "updated_at", null: false
> t.date "raceday"
> t.index ["season_id"], name: "index_days_on_season_id"
>   end
> 
>   create_table "points", force: :cascade do |t|
> t.text "place"
> t.text "riders"
> t.integer "racepoints"
> t.text "status"
> t.integer "race_id"
> t.datetime "created_at", null: false
> t.datetime "updated_at", null: false
> t.index ["race_id"], name: "index_points_on_race_id"
>   end
> 
>   create_table "races", force: :cascade do |t|
> t.boolean "display"
> t.text "racename"
> t.integer "season_id"
> t.integer "day_id"
> t.datetime "created_at", null: false
> t.datetime "updated_at", null: false
> t.text "raceclass"
> t.index ["day_id"], name: "index_races_on_day_id"
> t.index ["season_id"], name: "index_races_on_season_id"
>   end
> 
>   create_table "seasons", force: :cascade do |t|
> t.date "year"
> t.datetime "created_at", null: false
> t.datetime "updated_at", null: false
>   end
> 
> end
> 
> I want to end up with something like this for the race index.html.erb file
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> You select the season it then displays the days for the the selected season. 
> You then select the day and the races for that day are displayed.
> 
> The four tables are joined and the results is displayed in the Race Details.
> 
> My current points index.html is this.
> 
> <%= notice %>
> 
> Points
> 
>   
> 
>   Season
>   
> <%= collection_select(:season, :id, Season.all, :id, :year, {}, 
> {:multiple => false}) %>
>   
> 
>   
> 
>   
> 
>   Race Day
>   
> <%= collection_select(:day, :id, Day.all, :id, :raceday, {}, 
> {:multiple => false}) %>
>   
> 
>   
> 
>   
> 
>   Race Name
>   
> <%= collection_select(:race, :id, Race.all, :id, :racename, {}, 
> {:multiple => false}) %>
>   
> 
>   
> 
> 
> 
> I am thinking of using a grouped_collection_select to populate the relevant 
> dropdowns . I know I need to Jquery or javascript to pass the selected 
> options from one drop down to another .but can't get it to work 
> 
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/39724b42-3377-44b4-8171-7635059f1f13%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
> 

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/4426491F-C56F-4330-9EFE-6AB5C8B0189B%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] loading localhost:3000/projectszzzzz takes forever to load > 2min

2019-05-23 Thread Walter Lee Davis
Turn your logging level up to debug, and watch the queries that are being 
generated by ActiveRecord in order to load this route. Are you seeing multiple 
requests to the database, or one big honking joined query? Sometimes using 
joins is slower than eager loading (which generally loads in two or more 
queries). But for slow, nothing beats an N+1 query, where you load a bunch of 
objects, then make a separate query or more per object to gather associated 
records from other related models. 

Without any more details about your setup (running on a Raspberry Pi? or 
bouncing your database connection off the moon?) it's impossible to say. But 
start there.

Walter

> On May 23, 2019, at 3:02 PM, tom  wrote:
> 
> i have roughly 30 resources in routes, 10 scopes, a few nested resources.  
> how can i find out what the problem is?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMcMrB1ZLtn_v76RbW33vV1N-M%2B5Xypt3u1H-FBA342jDg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/67541D5B-D756-40C3-AC98-476C46D351BD%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] help...how do i get the "projects_path" from controller?

2019-05-21 Thread Walter Lee Davis
Oh, duh. I didn't read what you were asking. Please ignore my answer. Ariel has 
the right answer here.

Walter

> On May 21, 2019, at 3:06 PM, Ariel Juodziukynas  wrote:
> 
> You can pass the object to the link_to if you want to use the show url:
> 
> link_to 'Show', record
> 
> Rails will infere the show action with the proper controller and id from the 
> object's class
> 
> El mar., 21 may. 2019 a las 16:03, Walter Lee Davis () 
> escribió:
> You could use 
> 
> link_to 'Index', url_for(controller: controller_name, action: :index) 
> 
> instead. That would be agnostic of whichever controller was rendering that 
> _index.html.erb partial.
> 
> Walter
> 
> > On May 21, 2019, at 2:59 PM, tom  wrote:
> > 
> > yes i do:
> >   scope :pm do
> > get '/', :to => 'projects#dashboard',   :as=>'pm_dashboard' 
> > resources :project_resource_groups #, :path=>'tasks'
> > resources :project_programs
> > resources :projects
> > end
> > 
> > 
> > but again, the _index view partial is used in a lot index actions, so i 
> > dont know how to "pick" the right 'path' while creating the html table...
> > 
> > 
> > thx
> > 
> > 
> > On Tue, May 21, 2019 at 2:49 PM Walter Lee Davis  wrote:
> > The projects path isn't coming from the controller, it's coming from the 
> > routes file. Do you have any references in your routes.rb file that mention 
> > projects?
> > 
> > Walter
> > 
> > > On May 21, 2019, at 2:46 PM, tom  wrote:
> > > 
> > > hi, i have a generic _index partial, but i am struggling with 
> > > constrcuting the 
> > > 
> > > (link_to "show", ..(rec.id))
> > > 
> > > 
> > > how can i get that filled in? i have tried via url_for (controller & 
> > > action), but it always says: arguments passed to url_for can't be handled
> > > 
> > > please help
> > > 
> > > thx
> > > 
> > > 
> > > -- 
> > > You received this message because you are subscribed to the Google Groups 
> > > "Ruby on Rails: Talk" group.
> > > To unsubscribe from this group and stop receiving emails from it, send an 
> > > email to rubyonrails-talk+unsubscr...@googlegroups.com.
> > > To post to this group, send email to rubyonrails-talk@googlegroups.com.
> > > To view this discussion on the web visit 
> > > https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMcwBzUv9EYzHCEoN%2BZXDb4pEWt%2BU%2BKpbtO3Es375-xpug%40mail.gmail.com.
> > > For more options, visit https://groups.google.com/d/optout.
> > 
> > -- 
> > You received this message because you are subscribed to the Google Groups 
> > "Ruby on Rails: Talk" group.
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to rubyonrails-talk+unsubscr...@googlegroups.com.
> > To post to this group, send email to rubyonrails-talk@googlegroups.com.
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/rubyonrails-talk/AAAFA33B-6F38-44A6-87D2-E2CF7FBEE5D5%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+unsubscr...@googlegroups.com.
> > To post to this group, send email to rubyonrails-talk@googlegroups.com.
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMedP5BfQtZgsrAGcNPjhVTbfc28OZXG2yEtQgqNS1dXVQ%40mail.gmail.com.
> > For more options, visit https://groups.google.com/d/optout.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/256470F3-466D-4D69-9DFA-871582AF4F2C%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+unsubscr

Re: [Rails] help...how do i get the "projects_path" from controller?

2019-05-21 Thread Walter Lee Davis
You could use 

link_to 'Index', url_for(controller: controller_name, action: :index) 

instead. That would be agnostic of whichever controller was rendering that 
_index.html.erb partial.

Walter

> On May 21, 2019, at 2:59 PM, tom  wrote:
> 
> yes i do:
>   scope :pm do
> get '/', :to => 'projects#dashboard',   :as=>'pm_dashboard' 
> resources :project_resource_groups #, :path=>'tasks'
> resources :project_programs
> resources :projects
> end
> 
> 
> but again, the _index view partial is used in a lot index actions, so i dont 
> know how to "pick" the right 'path' while creating the html table...
> 
> 
> thx
> 
> 
> On Tue, May 21, 2019 at 2:49 PM Walter Lee Davis  wrote:
> The projects path isn't coming from the controller, it's coming from the 
> routes file. Do you have any references in your routes.rb file that mention 
> projects?
> 
> Walter
> 
> > On May 21, 2019, at 2:46 PM, tom  wrote:
> > 
> > hi, i have a generic _index partial, but i am struggling with constrcuting 
> > the 
> > 
> > (link_to "show", ..(rec.id))
> > 
> > 
> > how can i get that filled in? i have tried via url_for (controller & 
> > action), but it always says: arguments passed to url_for can't be handled
> > 
> > please help
> > 
> > thx
> > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google Groups 
> > "Ruby on Rails: Talk" group.
> > To unsubscribe from this group and stop receiving emails from it, send an 
> > email to rubyonrails-talk+unsubscr...@googlegroups.com.
> > To post to this group, send email to rubyonrails-talk@googlegroups.com.
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMcwBzUv9EYzHCEoN%2BZXDb4pEWt%2BU%2BKpbtO3Es375-xpug%40mail.gmail.com.
> > For more options, visit https://groups.google.com/d/optout.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/AAAFA33B-6F38-44A6-87D2-E2CF7FBEE5D5%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+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMedP5BfQtZgsrAGcNPjhVTbfc28OZXG2yEtQgqNS1dXVQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/256470F3-466D-4D69-9DFA-871582AF4F2C%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] help...how do i get the "projects_path" from controller?

2019-05-21 Thread Walter Lee Davis
The projects path isn't coming from the controller, it's coming from the routes 
file. Do you have any references in your routes.rb file that mention projects?

Walter

> On May 21, 2019, at 2:46 PM, tom  wrote:
> 
> hi, i have a generic _index partial, but i am struggling with constrcuting 
> the 
> 
> (link_to "show", ..(rec.id))
> 
> 
> how can i get that filled in? i have tried via url_for (controller & action), 
> but it always says: arguments passed to url_for can't be handled
> 
> please help
> 
> thx
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMcwBzUv9EYzHCEoN%2BZXDb4pEWt%2BU%2BKpbtO3Es375-xpug%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/AAAFA33B-6F38-44A6-87D2-E2CF7FBEE5D5%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] after_rollback on :create not triggered

2019-05-20 Thread Walter Lee Davis
It seems possible that the on: attribute is not referenced in the 
after_rollback callback. Is it listed in the documentation?

You could probably get the same result by adding a test inside your method:

after_rollback {
  return if persisted?
  // whatever else here
}

This will only ever proceed beyond that checkpoint if the record was in the 
process of being created, since on an update or delete, the record would be 
persisted (have an ID).

Walter

> On May 20, 2019, at 8:58 AM, Cevad Tokatlı  wrote:
> 
> I have a product table and I try to run after_commit and after_rollback on 
> create.
> 
> 
> 
> controller:
> 
>   product = Product.
> new form_params
>   
> if product.
> save
> 
> # code
> 
>   
> else
> 
> 
> # code
> 
>   
> end
> 
> 
> model:
> 
>   after_commit(on: :create) {
> 
> 
> # code
> 
>   
> }
> 
> 
>   after_rollback
> (on: :create) {
> 
> 
> # code
> 
>   
> }
> 
> 
> after_commit works well but after_rollback wont work with on: :create param. 
> When I remove the on: :create param, it triggers too but I need 
> after_rollback to trigger just on create.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/c0ad4f7b-d303-4fb8-8dc2-f72ea3517573%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/D5D2DF05-FC53-4915-A068-5C539ED40FF1%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] jquery drop down hover

2019-04-03 Thread Walter Lee Davis


> On Apr 3, 2019, at 8:05 PM, Joe Guerra  wrote:
> 
> my rails app is versio 5.0.7.
> 
> I did change //= jquery  to //=jquery3 (and it loaded jquery 3.3.1 in the 
> production environment on heroku).  
> 
> so that wasn't the issue, it's just that my jquery scripts don't seem to run 
> :( 
> 

One thing that I haven't heard about from you is whether they run in production 
mode anywhere else. Can you try running in production mode on your dev machine?

RAILS_ENV=production rake assets:precompile
RAILS_ENV=production rake db:migrate
rails s production

See if your scripts run okay there. If they do, then check that you are 
precompiling assets on your production server. (I am pretty sure that a heroku 
deploy will take care of all that automagically, but I haven't used it in 
several years, and I may have forgotten.)

If the problem was turbolinks, you would have seen that problem everywhere, in 
every environment. The usual way to fix that (if it's the reason) is to ensure 
that your scripts that run in the head of the page are properly listening for 
the turbolinks events, not page load, because the page load happens exactly 
once (when your first page loads) -- and never again -- in a turbolinks 
application. So anywhere you were using $.ready(), you would use 
$(document).on('turbolinks:load', function(evt){  /* your script here */ }); 
You can also just put any scripts that need access to the updated body in the 
very bottom of your layout, just inside the closing  tag.

Walter


> On Wednesday, April 3, 2019 at 11:40:38 AM UTC-4, jake wrote:
> I asked about the Rails version because these libs are incompatible with 
> Rails 5+ 
> https://github.com/jquery-ui-rails/jquery-ui-rails/issues/124#issuecomment-339689827
> 
> Rails 5+ uses the webpacker gem to load JS. 
> 
> On Wed, Apr 3, 2019 at 10:25 AM Joe Guerra  wrote:
> I have the following...
> 
> gem 'jquery-rails', '~> 4.3', '>= 4.3.1'
> gem 'jquery-ui-rails', '~> 6.0', '>= 6.0.1'
> 
> and I've looked at my heroku console, and did a gem list, it says I have the 
> latest jquery stuff...
> 
> jquery-rails (4.3.3)
> jquery-ui-rails (6.0.1) 
> 
> my gem.lock file is ok too.
> 
> jquery-rails (4.3.3)
> jquery-ui-rails (6.0.1)
> 
> 
> Is there any way in the browser console (or debugger to figure out what's 
> loading and when?)  
> 
> I feel it's related to turbolinks again, lol, always seems to be an issue 
> with turbolinks.
> 
> 
> 
> On Wednesday, April 3, 2019 at 10:23:37 AM UTC-4, Brandon McClelland wrote:
> It sounds to me like something isn't nailed down to a specific version of 
> jQuery so your latest dev builds just go grab whatever latest version they 
> can find but your Production machine hasn't had to do this process in some 
> time. 
> 
> In the Gemfile for the main Rails app I support, we have lines for 
> gem 'jquery-rails'
> gem 'jquery-ui-rails'
> and this is what actually prepares the server running the app with some 
> version of jQuery. You probably have something similar and that gem might 
> need to be updated on your production server (or specified more narrowly in 
> your Gemfile so your dev builds grab older versions of jQuery). You can check 
> the Gemfile.lock for specific version ranges of whatever gem is responsible 
> for your jQuery. 
> 
> If it's not a Gem that does this then you need to figure out how you got 
> jQuery onto your production server, how it gets there on your dev machine 
> builds, and how to stop your dev builds from grabbing a different version. 
> 
> On Tue, Apr 2, 2019 at 4:24 PM David Merrick  wrote:
> Have you checked your gem file and whats in application.js?
> 
> On Wed, Apr 3, 2019 at 9:54 AM Joe Guerra  wrote:
> No, that's in the gem file...
> 
> I even tried adding the jquery right to the application.erb from the Jquery 
> CND...
> 
>  src="https://code.jquery.com/jquery-3.3.1.min.js";
> integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
> crossorigin="anonymous">
> 
> Still loads 1.12.4, no idea where it's getting it from.  (or why 3.3.1 isn't 
> loading).
> 
> 
> On Tuesday, April 2, 2019 at 4:22:30 PM UTC-4, David Merrick wrote:
> Make sure you have the gem bootstrap sass could help
> 
> On Wed, 3 Apr 2019 9:03 AM Joe Guerra  wrote:
> ok, here's my application.js
> 
> // This is a manifest file that'll be compiled into application.js, which 
> will include all the files
> // listed below.
> //
> // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, 
> vendor/assets/javascripts,
> // or any plugin's vendor/assets/javascripts directory can be referenced here 
> using a relative path.
> //
> // It's not advisable to add code directly here, but if you do, it'll appear 
> at the bottom of the
> // compiled file.
> //
> // Read Sprockets README 
> (https://github.com/rails/sprockets#sprockets-directives) for details
> // about supported directives.
> //
> //= 

Re: [Rails] Fetch check box id's into arry from one table to other table

2019-03-25 Thread Walter Lee Davis


> On Mar 25, 2019, at 7:37 AM, Piyush Chowhan  wrote:
> 
> Hi,
> 
> 
> <%= f.check_box :tax_rates, :name => "tax_group[tax_rates][]", :value => 
> tax_rate.id  %>
> 
> I want to fetch tax_rate.id to other table which is selected in the check 
> box? 
> 
> The check box which is selected those id's I want to fetch in other table 
> inside a parameter in array.
> 
> Multiple check box's are selected want those selected check box id's in to 
> array in the other table of params 

Can you say a little more about your problem? It's not clear from the 
explanation above exactly what you're trying to do. Are you trying to get the 
values from the array of check boxes in a controller, and assign them to a 
different set of parameters?

Are you trying to do something in the page itself (maybe with JavaScript) to 
cause one set of check boxes to act on a different set of check boxes in the 
same page?

What do your parameters look like (in the development console) when you submit 
this form?

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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/404B3A61-FE90-4FFD-8FBA-301B8ECE09A2%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] How do you generically call a scope on a model?

2019-03-17 Thread Walter Lee Davis
I want to (in a metaprogramming context) invoke a scope on an ActiveRecord 
based model. I know the name of the scope, but I don't want to use `send` to do 
this, because send can be evil. I know that ActiveRecord defines a class method 
named scope that gathers up these scopes somewhere internally, but I can't 
figure out where that is, or how you can pick one out of the stack to execute.

What is the best equivalent to this (completely made-up example):

def call_scope(model, scope = 'all')
  model.send scope.to_sym
end

The key feature is that we late-evaluate which model and which scope, so it can 
be used inside an enumerator, and doesn't rely on knowing the exact parties in 
play. 

Would this be a good place for class_eval? (I just tried that, and it works)

def call_scope(model, scope = 'all')
  model.class_eval scope.to_s
end

Is there something more Rails-like I could/should use?

Am I wrong about send?

Thanks in advance,

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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/96E23293-FE9C-486D-84B2-935D1203E7BB%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Leaking authenticity_token in logs

2019-03-16 Thread Walter Lee Davis
They are only valid for 15 minutes and then they are never going to work again. 
They don't matter. I suppose if you had enough of them you could brute-force 
out what the secret key was, but that's a nation-state level of effort. Are 
your users (or their haters) in that league?

Walter

> On Mar 16, 2019, at 2:19 AM, 0x01  wrote:
> 
> If these logs get compromised, can these tokens be used again (i.e. are these 
> tokens reusable?)
> 

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/1CCD8127-E212-40C5-A2E2-840E659B745B%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Sass-rails

2019-03-10 Thread Walter Lee Davis


> On Mar 10, 2019, at 6:17 PM, brainiacs...@gmail.com wrote:
> 
> Hi Everyone,
> 
> I was just curious as to what everyone is using since sass-rails is 
> depreciating and if I add a ui kit it should change the look and feel of the 
> app without have to change a great deal of the css. Correct?

I'm not aware of the sass-rails gem being deprecated, only the sass gem itself, 
which is a gemspec dependency of sass-rails. We've had good luck using the 
sassc gem as a replacement for that. Just add it to your gemfile along with 
sass-rails and you should be all set.

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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/BDD1890F-D9D1-4CFC-8101-403AE019DD12%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Rake aborted!

2019-03-10 Thread Walter Lee Davis
Correct. Your server does not have a JavaScript interpreter available at the 
command line. These days, I just install whatever version of NodeJS is in the 
package manager for that server. If you want to avoid any server dependencies, 
you can just add therubyracer to your Gemfile and bundle on the server will 
install that. That's a JS interpreter written entirely in vanilla Ruby.

Walter

> On Mar 10, 2019, at 1:21 PM, brainiacs...@gmail.com wrote:
> 
> Yes I did. Where I was thrown off is in trying to understand what the literal 
> issue is so I could resolve it as my understanding was if there were any 
> outstanding issues with the app it wouldnt bundle I assumed the issue to be 
> OS related. I 
> 
> On Sunday, March 10, 2019 at 1:10:22 PM UTC-4, Hassan Schroeder wrote:
> On Sun, Mar 10, 2019 at 9:45 AM  wrote: 
> 
> > Now that the bundle install has run successfully I have run into the 
> > following error while running rake db:create. Does anyone have any ideas 
> > how to resolve the issue? 
> 
> > rake aborted! 
> > ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See 
> > https://github.com/rails/execjs for a list of available runtimes. 
> 
> Did you follow the link in the message? 
> 
> -- 
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/c9b83824-b33c-4645-ba0b-84ec0d799494%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/9ADF24EF-B643-4E3C-A0B8-970B38963679%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Database dump and import

2019-03-10 Thread Walter Lee Davis
Just the schema. For the data, you'd need to run a backup utility of some sort. 
On MySQL, there's mysqldump, I'm pretty sure there's similar on the Postgres 
side, so no matter which direction you want to go, you'd be set. Be sure to 
only dump the data, not the structure, if you're using the schema:dump 
technique. Rails' database adapters are smart, and they can do the exact same 
structure with all the local weirdnesses that are required by the respective 
engines.

Walter

> On Mar 10, 2019, at 5:58 AM, Rob Jonson  wrote:
> 
> bundle exec rails db:schema:dump
> 
> does this dump the data, or just the schema?
> 
> I would assume just the schema - and that to transfer the data you'll need to 
> use something like the solutions here:
> https://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL#MySQL
>  
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/5fcb6342-219a-41d8-882b-1ada288d%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/E0E67B86-7DB3-4CBC-9C50-8B867F7ACAD6%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


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

2019-03-08 Thread Walter Lee Davis


> On Mar 8, 2019, at 9:18 AM, Colin Law  wrote:
> 
> On Fri, 8 Mar 2019 at 13:05, Robert Phillips
>  wrote:
>> ...
>> I don't mean to sound patronizing
> 
> Not sure you have succeeded in that.
> 
>> ...
>> Also you were trying to tell me that the routes file has a root in there 
>> explicitly by default.
> 
> No I wasn't.  I was asking.  I have just tried it and mine does have a
> root line in there, commented out.
>  # root 'welcome#index'
> 
> That is with Rails 4.2
> 
> Colin

That line seems to have been removed somewhere along the way to 5.1 or 2, can't 
recall which version my stunt app used. More "cleanliness is next to impossible 
to debug".

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+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLv%2BB0ZXKyA7-whJQQcWyysA-kTWoWtrjaCKhrUhOssrUw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/962871AA-6707-4808-B85F-D508A25294FD%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


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

2019-03-08 Thread Walter Lee Davis


> On Mar 8, 2019, at 7:40 AM, Colin Law  wrote:
> 
> On Fri, 8 Mar 2019 at 12:19, Robert Phillips
>  wrote:
>> 
>> 
>> 
>> On Friday, 8 March 2019 12:07:16 UTC, Colin Law wrote:
>>> 
>>> 
>>> You can reference any controller/action in the routes.  Welcome#index
>>> is no different to any other.  Reference it exactly the same way as
>>> you would reference any controller#action.
>> 
>> 
>> Would be all lowercase. (as with all controllers , they have an uppercase 
>> letter in some parts of rails, but in the config/routes.rb file they are all 
>> lowercase)
>> 
>> I have tried get '/abc', to:'welcome#index'
>> 
>> or
>>   root 'welcome#index'
>> 
>> 
>> And doesn't work.
>> 
>> I get uninitialized constant WelcomeController
> 
> Have you got a controller called WelcomeController?  If not then what
> is the name of the controller with method index?
> 
> Colin
> 

It is WelcomeController, but it's inside the Rails gem, so it's 
Rails::WelcomeController:

Started GET "/" for 127.0.0.1 at 2019-03-08 07:53:01 -0500
   (0.3ms)  SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER 
BY "schema_migrations"."version" ASC
  ↳ 
/Volumes/eddy/Users/waltd/.rvm/gems/ruby-2.4.4/gems/activerecord-5.2.2/lib/active_record/log_subscriber.rb:98
Processing by Rails::WelcomeController#index as HTML

That's the controller you'll need to reference in your route. I am not at all 
sure how you would do this in the routes syntax, but maybe something like this 
would work:

get '/foo', to: 'rails/welcome#index'

Experiment with that angle, or read the Rails API to see if there's another 
syntax you can use. There's something useful in the Rails Guide "Routing from 
the outside in" that might work:

scope module: 'rails' do
  get '/foo', to: 'welcome#index'
end

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+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLv4JqvtXmHCDOuLCWo23DOP0o68CPDuB6eaLzkX-kk6eg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/DCAD-AE53-4F5B-A69E-6D073424CD4C%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Has anyone seen these errors?

2019-03-07 Thread Walter Lee Davis
Okay. Do you know how to figure out which versions you have installed?

gem list bundler

will show you a list of the currently installed versions of the gem. You can 
install any particular version you want, or if you find one that is in the 
range you noted in the error message, use that in place of _2.0.0_.

Walter

> On Mar 7, 2019, at 1:54 PM, brainiacs...@gmail.com wrote:
> 
> Hi Walter,
> 
> That is what I ran that gave me the latest set of errors that you see. What I 
> am trying to do now is figure out how to eliminate the errors so it is clean.
> 
> Thanks,
> 
> On Thursday, March 7, 2019 at 1:48:36 PM UTC-5, Walter Lee Davis wrote:
> Someone else answered this already. Use the _underscore_ trick to force a 
> particular version of bundler to run the command: 
> 
> bundle _2.0.0_ update ... 
> 
> See if that works. 
> 
> Walter 
> 
> > On Mar 7, 2019, at 1:03 PM, braini...@gmail.com wrote: 
> > 
> > Hi David and Walter and everyone else, 
> > 
> > I ran the bundle update and now here is what seems to be the issue: 
> > 
> > Bundler could not find compatible versions for gem "bundler": 
> >   In Gemfile: 
> > rails (= 4.2.4) was resolved to 4.2.4, which depends on 
> >   bundler (>= 1.3.0, < 2.0) 
> > 
> >   Current Bundler version: 
> > bundler (2.0.1) 
> > This Gemfile requires a different version of Bundler. 
> > Perhaps you need to update Bundler by running `gem install bundler`? 
> > 
> > Could not find gem 'bundler (>= 1.3.0, < 2.0)', which is required by gem 
> > 'rails 
> > (= 4.2.4)', in any of the sources. 
> > 
> > Bundler could not find compatible versions for gem "coffee-rails": 
> >   In Gemfile: 
> > coffee-rails (~> 4.1.0) 
> > 
> > rails_admin was resolved to 1.4.2, which depends on 
> >   coffee-rails (~> 4.0) 
> > 
> > Bundler could not find compatible versions for gem "jwt": 
> >   In Gemfile: 
> > jwt 
> > 
> > opentok was resolved to 2.4.0, which depends on 
> >   jwt (~> 1.5.6) 
> > 
> > twilio-ruby was resolved to 5.21.1, which depends on 
> >   jwt (>= 1.5, <= 2.5) 
> > 
> > Bundler could not find compatible versions for gem "rails": 
> >   In Gemfile: 
> > rails (= 4.2.4) 
> > 
> > griddler was resolved to 1.5.2, which depends on 
> >   rails (>= 3.2.0) 
> > 
> > moonclerk was resolved to 1.0.3, which depends on 
> >   rails (>= 4.1) 
> > 
> > rails_admin was resolved to 1.4.2, which depends on 
> >   rails (>= 4.0, < 6) 
> > 
> > Bundler could not find compatible versions for gem "ruby": 
> >   In Gemfile: 
> > ruby (~> 2.3.8.0) 
> > 
> > active_record-acts_as was resolved to 4.0.0, which depends on 
> >   ruby (>= 2.4) 
> > 
> > 
> > 
> > I believe that I need to do some gemfile changes namely the bundle and the 
> > coffee-rails issue. What are your thoughts? 
> > 
> > -- 
> > 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/398361a4-8e93-4580-8657-71f42a38e269%40googlegroups.com.
> >  
> > For more options, visit https://groups.google.com/d/optout. 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/c3f39240-e453-4085-853a-3f9e86b4ed99%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/87769015-939F-4579-8279-EE90E42F7B36%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Has anyone seen these errors?

2019-03-07 Thread Walter Lee Davis
Someone else answered this already. Use the _underscore_ trick to force a 
particular version of bundler to run the command:

bundle _2.0.0_ update ...

See if that works.

Walter

> On Mar 7, 2019, at 1:03 PM, brainiacs...@gmail.com wrote:
> 
> Hi David and Walter and everyone else,
> 
> I ran the bundle update and now here is what seems to be the issue:
> 
> Bundler could not find compatible versions for gem "bundler":
>   In Gemfile:
> rails (= 4.2.4) was resolved to 4.2.4, which depends on
>   bundler (>= 1.3.0, < 2.0)
> 
>   Current Bundler version:
> bundler (2.0.1)
> This Gemfile requires a different version of Bundler.
> Perhaps you need to update Bundler by running `gem install bundler`?
> 
> Could not find gem 'bundler (>= 1.3.0, < 2.0)', which is required by gem 
> 'rails
> (= 4.2.4)', in any of the sources.
> 
> Bundler could not find compatible versions for gem "coffee-rails":
>   In Gemfile:
> coffee-rails (~> 4.1.0)
> 
> rails_admin was resolved to 1.4.2, which depends on
>   coffee-rails (~> 4.0)
> 
> Bundler could not find compatible versions for gem "jwt":
>   In Gemfile:
> jwt
> 
> opentok was resolved to 2.4.0, which depends on
>   jwt (~> 1.5.6)
> 
> twilio-ruby was resolved to 5.21.1, which depends on
>   jwt (>= 1.5, <= 2.5)
> 
> Bundler could not find compatible versions for gem "rails":
>   In Gemfile:
> rails (= 4.2.4)
> 
> griddler was resolved to 1.5.2, which depends on
>   rails (>= 3.2.0)
> 
> moonclerk was resolved to 1.0.3, which depends on
>   rails (>= 4.1)
> 
> rails_admin was resolved to 1.4.2, which depends on
>   rails (>= 4.0, < 6)
> 
> Bundler could not find compatible versions for gem "ruby":
>   In Gemfile:
> ruby (~> 2.3.8.0)
> 
> active_record-acts_as was resolved to 4.0.0, which depends on
>   ruby (>= 2.4)
> 
> 
> 
> I believe that I need to do some gemfile changes namely the bundle and the 
> coffee-rails issue. What are your thoughts?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/398361a4-8e93-4580-8657-71f42a38e269%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/BC6ABBB6-8D35-47A5-B31E-5DD093A38B88%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Has anyone seen these errors?

2019-03-07 Thread Walter Lee Davis
It sounds like you want to run bundle update to get your gems to update in 
concert. There are a lot of options in this area of bundler; read the docs, or 
browse bundle update --help in the console to see what you can do. Definitely 
make sure you have a new git branch if you start running this without the 
brakes on. It is very easy to end up with a whole cluster of changes that are 
difficult to resolve, particularly if you haven't done this in a while.

Walter

> On Mar 7, 2019, at 12:47 PM, brainiacs...@gmail.com wrote:
> 
> Hi everyone,
> 
> Has anyone seen the following issues and if so how did you resolve them?
> 
> Bundler could not find compatible versions for gem "bundler":
>   In Gemfile:
> rails (= 4.2.4) was resolved to 4.2.4, which depends on
>   bundler (>= 1.3.0, < 2.0)
> 
>   Current Bundler version:
> bundler (2.0.1)
> This Gemfile requires a different version of Bundler.
> Perhaps you need to update Bundler by running `gem install bundler`?
> 
> Could not find gem 'bundler (>= 1.3.0, < 2.0)', which is required by gem 
> 'rails
> (= 4.2.4)', in any of the sources.
> 
> Bundler could not find compatible versions for gem "coffee-rails":
>   In Gemfile:
> coffee-rails (~> 4.1.0)
> 
> rails_admin was resolved to 1.4.2, which depends on
>   coffee-rails (~> 4.0)
> 
> Bundler could not find compatible versions for gem "jwt":
>   In Gemfile:
> jwt
> 
> opentok was resolved to 2.4.0, which depends on
>   jwt (~> 1.5.6)
> 
> twilio-ruby was resolved to 5.21.1, which depends on
>   jwt (>= 1.5, <= 2.5)
> 
> Bundler could not find compatible versions for gem "rails":
>   In Gemfile:
> rails (= 4.2.4)
> 
> griddler was resolved to 1.5.2, which depends on
>   rails (>= 3.2.0)
> 
> moonclerk was resolved to 1.0.3, which depends on
>   rails (>= 4.1)
> 
> rails_admin was resolved to 1.4.2, which depends on
>   rails (>= 4.0, < 6)
> 
> Bundler could not find compatible versions for gem "ruby":
>   In Gemfile:
> ruby (~> 2.3.8.0)
> 
> active_record-acts_as was resolved to 4.0.0, which depends on
>   ruby (>= 2.4)
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/7ec36144-3d46-4248-b6f0-23fc07d5ced9%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/576DAEEC-7341-414F-9506-81E44881C56D%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Problem serving image assets

2019-03-06 Thread Walter Lee Davis


> On Mar 6, 2019, at 10:29 AM, Walter Lee Davis  wrote:
> 
>> 
>> On Mar 6, 2019, at 10:16 AM, Colin Law  wrote:
>> 
>> On Wed, 6 Mar 2019 at 14:47, Walter Lee Davis  wrote:
>>> 
>>> 
>>>> On Mar 6, 2019, at 9:27 AM, Walter Lee Davis  wrote:
>>>> 
>>>> The asset pipeline needs a JavaScript interpreter to work correctly on the 
>>>> server. I usually install whatever version of Node.js is available in a 
>>>> package manager. Alternatively, you can use the gem `therubyracer` to do 
>>>> the same thing. If you have that dependency filled, then I'm fresh out of 
>>>> ideas.
>> 
>> Thanks for the suggestions Walter
>> I have checked nodejs is installed (node -v shows 10.x)
>> 
>>> 
>>> Make sure that this works, on the server:
>>> 
>>> RAILS_ENV=production rake assets:precompile
>> 
>> Yes it does work, it outputs nothing, as expected.  The code has been
>> checked out of the git repo, which doesn't include the public/assets
>> folder and the compiled assets are there ok.
>> I just realised that I was wrong about the css, that isn't found either.
>> 
>> One thing that confuses me, in the nginx log I see entries like
>> GET /assets/red_pin.png HTTP/1.1" 404 457 ...
>> Should the url not be the full name including the digest?
> 
> Yes, at the NGINX level, the request should be for the actual file path. In 
> the Rails app, there would be a helper call like asset_url('red_pin.png'), 
> which would generate the full path including the fingerprint. 

I just realized this answer wasn't entirely clear. When I said the "actual file 
path", I meant including the fingerprint. 

Another idea: have a hunt in the rake -T output for assets things you can do. 
One of them is purge or flush or something like that. Really get in there and 
force it to re-do everything.

Walter

> 
>> Even more confusingly I am informed that if I access the server from
>> another location then the images do appear, but I wonder whether that
>> one is seeing cached images.  I haven't managed to capture the log
>> when that site issues a full refresh yet.
> 
> Yes. If you want to bust the cache, there's an assets_version config 
> attribute you can change. I think it's 1 by default, and you can increment 
> it, and then precompile assets. Everything will change. But the question you 
> have above would trump that, I think.
> 
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/6127B556-0CB8-43CF-913D-A13BF4F60E26%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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/0B78C247-4879-49B0-9EB4-3F18D030ABB4%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Problem serving image assets

2019-03-06 Thread Walter Lee Davis


> On Mar 6, 2019, at 10:16 AM, Colin Law  wrote:
> 
> On Wed, 6 Mar 2019 at 14:47, Walter Lee Davis  wrote:
>> 
>> 
>>> On Mar 6, 2019, at 9:27 AM, Walter Lee Davis  wrote:
>>> 
>>> The asset pipeline needs a JavaScript interpreter to work correctly on the 
>>> server. I usually install whatever version of Node.js is available in a 
>>> package manager. Alternatively, you can use the gem `therubyracer` to do 
>>> the same thing. If you have that dependency filled, then I'm fresh out of 
>>> ideas.
> 
> Thanks for the suggestions Walter
> I have checked nodejs is installed (node -v shows 10.x)
> 
>> 
>> Make sure that this works, on the server:
>> 
>> RAILS_ENV=production rake assets:precompile
> 
> Yes it does work, it outputs nothing, as expected.  The code has been
> checked out of the git repo, which doesn't include the public/assets
> folder and the compiled assets are there ok.
> I just realised that I was wrong about the css, that isn't found either.
> 
> One thing that confuses me, in the nginx log I see entries like
> GET /assets/red_pin.png HTTP/1.1" 404 457 ...
> Should the url not be the full name including the digest?

Yes, at the NGINX level, the request should be for the actual file path. In the 
Rails app, there would be a helper call like asset_url('red_pin.png'), which 
would generate the full path including the fingerprint. 

> Even more confusingly I am informed that if I access the server from
> another location then the images do appear, but I wonder whether that
> one is seeing cached images.  I haven't managed to capture the log
> when that site issues a full refresh yet.

Yes. If you want to bust the cache, there's an assets_version config attribute 
you can change. I think it's 1 by default, and you can increment it, and then 
precompile assets. Everything will change. But the question you have above 
would trump that, I think.

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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/6127B556-0CB8-43CF-913D-A13BF4F60E26%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Problem serving image assets

2019-03-06 Thread Walter Lee Davis


> On Mar 6, 2019, at 9:27 AM, Walter Lee Davis  wrote:
> 
>> 
>> On Mar 6, 2019, at 7:15 AM, Colin Law  wrote:
>> 
>> I hope someone can help me with an assets problem.  I have had to
>> rebuild a production server and images are no longer getting served.
>> Unfortunately the working system is no more so I can't compare what I
>> have with what used to work in order to help diagnose the problem.
>> 
>> I am using Rails 4.2 with nginx on an Ubuntu 16.04 server with
>> capistrano to deploy it and I have not changed the application (which
>> is git controlled).  However it is now running on a later version of
>> Ubuntu so the tools there have been updated, including nginx.
>> 
>> The problem is that image assets are not being served, the javascript
>> and css are working.  I can see (on the server) that the assets have
>> been precompiled and I can see in public/assets image files such as
>> blue_pin-.png where  is a big long number.
>> However in the browser console I can see it attempt to fetch
>> /assets/blue_pin.png without the digest, and this fails.
>> 
>> The code in the app that references the image is in coffescript and is a line
>> @marker_icon_blue = new OpenLayers.Icon('/assets/blue_pin.png', size, 
>> offset);
>> 
>> I used to know how all this is supposed to work, but I have been away
>> from Rails for a while and the brain cells seem to have atrophied
>> rather, and perusing the docs has failed to re-invigorate them
>> sufficiently, so if someone could suggest what might be going on I
>> would be very grateful.
>> 
>> Colin
> 
> The asset pipeline needs a JavaScript interpreter to work correctly on the 
> server. I usually install whatever version of Node.js is available in a 
> package manager. Alternatively, you can use the gem `therubyracer` to do the 
> same thing. If you have that dependency filled, then I'm fresh out of ideas.
> 
> Walter

Other than, of course, making sure you have sprockets and sprockets-rails 
listed in your Gemfile.lock. But you said you had run the rake 
assets:precompile task, or at least I assumed you had, if you said that your 
assets were precompiled already. Make sure that this works, on the server:

RAILS_ENV=production rake assets:precompile

If you do that, and you don't get any errors, you'll have two possible 
outcomes: 

1. You'll get an output line for each asset (maybe two lines, with one being 
.gz of the previous).
2. You'll get nothing at all (this is okay and normal, it means that the assets 
did not change since the last invocation of the command).

If you started up a new server, it may have a different secret key or assets 
version, and that would change the fingerprints on all the precompiled assets. 
Running the precompile step again would fix that.

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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/D57C1273-E186-4B74-9D94-7D3E854E0FCE%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Problem serving image assets

2019-03-06 Thread Walter Lee Davis


> On Mar 6, 2019, at 7:15 AM, Colin Law  wrote:
> 
> I hope someone can help me with an assets problem.  I have had to
> rebuild a production server and images are no longer getting served.
> Unfortunately the working system is no more so I can't compare what I
> have with what used to work in order to help diagnose the problem.
> 
> I am using Rails 4.2 with nginx on an Ubuntu 16.04 server with
> capistrano to deploy it and I have not changed the application (which
> is git controlled).  However it is now running on a later version of
> Ubuntu so the tools there have been updated, including nginx.
> 
> The problem is that image assets are not being served, the javascript
> and css are working.  I can see (on the server) that the assets have
> been precompiled and I can see in public/assets image files such as
> blue_pin-.png where  is a big long number.
> However in the browser console I can see it attempt to fetch
> /assets/blue_pin.png without the digest, and this fails.
> 
> The code in the app that references the image is in coffescript and is a line
> @marker_icon_blue = new OpenLayers.Icon('/assets/blue_pin.png', size, offset);
> 
> I used to know how all this is supposed to work, but I have been away
> from Rails for a while and the brain cells seem to have atrophied
> rather, and perusing the docs has failed to re-invigorate them
> sufficiently, so if someone could suggest what might be going on I
> would be very grateful.
> 
> Colin

The asset pipeline needs a JavaScript interpreter to work correctly on the 
server. I usually install whatever version of Node.js is available in a package 
manager. Alternatively, you can use the gem `therubyracer` to do the same 
thing. If you have that dependency filled, then I'm fresh out of ideas.

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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/502910B4-C0E2-45D2-B045-21B729C8323E%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Devise

2019-02-25 Thread Walter Lee Davis
What do the errors look like? When you say it doesn't work, what exactly are 
you seeing?

Walter

> On Feb 25, 2019, at 4:56 PM, David Merrick  wrote:
> 
> Hi Rob at the moment only the password reset email works. Are you able to 
> check them please?
> 
> Password reset
> 
> Hello <%= @resource.email %>!
> 
> Someone has requested a link to change your password. You can do this 
> through the link below.
> 
> <%= link_to 'Change my password', edit_password_url(@resource, 
> reset_password_token: @token) %>
> 
> If you didn't request this, please ignore this email.
> Your password won't change until you access the link above and create a 
> new one.
> 
> Confirmations dosen't
> 
> Welcome <%= @email %>!
> 
> You can confirm your account email through the link below:
> 
> <%= link_to 'Confirm my account', confirmation_url(@resource, 
> confirmation_token: @token) %>
> 
> Email changed doesn't
> 
> Hello <%= @email %>!
> 
> <% if @resource.try(:unconfirmed_email?) %>
>   We're contacting you to notify you that your email is being changed to 
> <%= @resource.unconfirmed_email %>.
> <% else %>
>   We're contacting you to notify you that your email has been changed to 
> <%= @resource.email %>.
> <% end %>
> 
> Cheers Dave
> 
> On Tue, Feb 26, 2019 at 10:40 AM Rob Jonson  wrote:
> What problem are you having?
> I have always found it worked pretty much out of the box (assuming you have 
> set up your mail config)
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/8481c189-06b0-4068-8716-587518893cd0%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
> 
> 
> -- 
> Dave Merrick
> 
> Daves Web Designs
> 
> Website http://www.daveswebdesigns.co.nz
> 
> Email merrick...@gmail.com
> 
> Ph   03 216 2053
> 
> Cell 027 3089 169
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/CA%2B%3DMcKaCp1hGMDa_pz__x7aUiu3H7VMZjmcwHdZMdUMgKeMeqw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/F330F48E-3A1D-4DF4-8AB3-CC69BD4F843D%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] What is the mysql equivalent to heroku pg:reset DATABASE?

2019-02-23 Thread Walter Lee Davis
That is the command-line:

cd /path/to/your/app
rake db:reset RAILS_ENV=production (or whatever)

That will do the whole job. It will drop the database, re-create it, and build 
up all the tables from the schema.rb.

Walter

> On Feb 23, 2019, at 7:30 PM, brainiacs...@gmail.com wrote:
> 
> Thank you Walter. What if I am performing the task from a command line?
> 
> On Saturday, February 23, 2019 at 7:21:36 PM UTC-5, Walter Lee Davis wrote:
> You can use rake db:reset in your Rails root, with the correct RAILS_ENV= set 
> in the same line. Your database user (as configured in the database.yml file) 
> will have to have the authority to drop the database. 
> 
> Walter 
> 
> > On Feb 23, 2019, at 6:18 PM, braini...@gmail.com wrote: 
> > 
> > Hey Everyone, 
> > 
> > I was just wondering if anyone knew the mysql equivalent to $ heroku 
> > pg:reset DATABASE. 
> > 
> > Thank you 
> > 
> > 
> > -- 
> > 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/80629938-6c4d-435e-8e3a-ea0077a8dad0%40googlegroups.com.
> >  
> > For more options, visit https://groups.google.com/d/optout. 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/face91e8-6313-41f7-9209-09db2bd9652c%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/BB6579DA-C026-4E9D-BDD2-0D5C503D9DAB%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] What is the mysql equivalent to heroku pg:reset DATABASE?

2019-02-23 Thread Walter Lee Davis
You can use rake db:reset in your Rails root, with the correct RAILS_ENV= set 
in the same line. Your database user (as configured in the database.yml file) 
will have to have the authority to drop the database.

Walter

> On Feb 23, 2019, at 6:18 PM, brainiacs...@gmail.com wrote:
> 
> Hey Everyone,
> 
> I was just wondering if anyone knew the mysql equivalent to $ heroku pg:reset 
> DATABASE.
> 
> Thank you
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/80629938-6c4d-435e-8e3a-ea0077a8dad0%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/6A704602-0F9C-4862-BC3E-4F26C6EA0F92%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Gemfile with mysql

2019-02-18 Thread Walter Lee Davis


> On Feb 18, 2019, at 2:02 PM, brainiacs...@gmail.com wrote:
> 
> Hey Everyone,
> 
> I am updating a gemfile so it uses mysql rather than sqllite or progres. 
> Would someone advise me to what I need to swap out in the gemfile so this 
> happens flawlessly?

One of the easiest ways to figure this out is to use the Rails generator to 
make a new "stunt" app with the -d or --database option specified to whichever 
database gem you would use:

rails new stunt_app -d mysql

And then look at the Gemfile and the config/database.yml files to see the major 
differences.

rails new stunt_app_2 -d sqlite3

Do the same thing with the database gem you are currently using so you can diff 
the directories, just give it a slightly different app name. You can delete the 
apps when you're done. You can get a list of available options by issuing the 
command rails new --help and scrolling down to -d.

Walter

> 
> Thank you
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/df136466-6070-4177-b180-9d69e854b484%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/A6514C57-E4DA-4E92-BFFD-9F2D6742788E%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Issue with connecting to oracle database

2019-02-12 Thread Walter Lee Davis


> On Feb 12, 2019, at 9:14 AM, shashank tiwari  wrote:
> 
> I am not getting your question could you please explain me in detail

Is this error message coming from your production server, or your development 
computer (laptop/desktop)? If this is your development machine, which one of 
the free installer packages from Oracle did you install on that machine? I have 
never used Windows for anything, but I have to use Oracle for my day job, and 
there's a whole bunch of software that you have to install if you want to use 
Oracle for development. If you're using Oracle on a production server, then 
this question is probably best handled by your DBA. If you're using Oracle in 
production without hiring a DBA, you are probably going to have a very long 
road ahead of you.

Walter

> 
> On Tue, Feb 12, 2019, 7:42 PM Walter Lee Davis  
> > On Feb 12, 2019, at 5:53 AM, shashank tiwari  wrote:
> > 
> > irb(main):004:0> require 'ruby-oci8'
> > LoadError: Cannot find OCI.DLL in PATH.
> > from 
> > C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/ruby-oci8-2.2.7-x64-mingw32/lib/oci8/check_load_error.rb:42:in
> >  `check_os_specific_load_error'
> > from 
> > C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/ruby-oci8-2.2.7-x64-mingw32/lib/oci8/check_load_error.rb:138:in
> >  `check_load_error'
> > from 
> > C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/ruby-oci8-2.2.7-x64-mingw32/lib/oci8.rb:110:in
> >  `rescue in '
> > from 
> > C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/ruby-oci8-2.2.7-x64-mingw32/lib/oci8.rb:114:in
> >  `'
> > from 
> > C:/tools/ruby23/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in 
> > `require'
> > from 
> > C:/tools/ruby23/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in 
> > `require'
> > from 
> > C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/ruby-oci8-2.2.7-x64-mingw32/lib/ruby-oci8.rb:1:in
> >  `'
> > from 
> > C:/tools/ruby23/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in 
> > `require'
> > from 
> > C:/tools/ruby23/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in 
> > `rescue in require'
> > from 
> > C:/tools/ruby23/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in 
> > `require'
> > from (irb):4
> > from C:/tools/ruby23/bin/irb.cmd:19:in `'
> 
> Is this your server, or your workstation? If the latter, did you install the 
> instant client or the development package?
> 
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/5C7AF4D3-9100-4970-A35C-49F4979C0BBB%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+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/CA%2Bob%2BdE5n4kFnG9sKU4wsmewG97J0TsGMk4x1U4-VrU_vfE8Qg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/A827D017-8887-4FF0-9AEF-F11BD3332D84%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Issue with connecting to oracle database

2019-02-12 Thread Walter Lee Davis


> On Feb 12, 2019, at 5:53 AM, shashank tiwari  wrote:
> 
> irb(main):004:0> require 'ruby-oci8'
> LoadError: Cannot find OCI.DLL in PATH.
> from 
> C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/ruby-oci8-2.2.7-x64-mingw32/lib/oci8/check_load_error.rb:42:in
>  `check_os_specific_load_error'
> from 
> C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/ruby-oci8-2.2.7-x64-mingw32/lib/oci8/check_load_error.rb:138:in
>  `check_load_error'
> from 
> C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/ruby-oci8-2.2.7-x64-mingw32/lib/oci8.rb:110:in
>  `rescue in '
> from 
> C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/ruby-oci8-2.2.7-x64-mingw32/lib/oci8.rb:114:in
>  `'
> from 
> C:/tools/ruby23/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in 
> `require'
> from 
> C:/tools/ruby23/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in 
> `require'
> from 
> C:/tools/ruby23/lib/ruby/gems/2.3.0/gems/ruby-oci8-2.2.7-x64-mingw32/lib/ruby-oci8.rb:1:in
>  `'
> from 
> C:/tools/ruby23/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in 
> `require'
> from 
> C:/tools/ruby23/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in 
> `rescue in require'
> from 
> C:/tools/ruby23/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in 
> `require'
> from (irb):4
> from C:/tools/ruby23/bin/irb.cmd:19:in `'

Is this your server, or your workstation? If the latter, did you install the 
instant client or the development package?

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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/5C7AF4D3-9100-4970-A35C-49F4979C0BBB%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Adding uploaded pictures fro Heroku to AWS S3 Bucket

2019-02-07 Thread Walter Lee Davis


> On Feb 7, 2019, at 3:25 AM, David Merrick  wrote:
> 
> I'm not using carrier wave. I'm using paperclip.

Yes, but the same rules apply (on the S3 side) for any attachment system. 

Walter

> 
> On Thu, Feb 7, 2019 at 9:05 PM Ryan  wrote:
> Hi David,
> 
> Check out this SO article that references S3 bucket permissions. Carrierwave 
> needs to be able to write to the S3 bucket. Ensure your bucket has Put 
> permissions.
> 
> 
> On Wednesday, February 6, 2019 at 8:31:10 PM UTC-8, David Merrick wrote:
> Current errors 500 Internal Server Error and Aws::S3::Errors::AccessDenied
> 
> My paperclip.rb in config/initializers is below
> 
> Paperclip::Attachment.default_options[:url] = ':s3_domain_url'  # Should this 
> line have instead of this ':s3_domain_url'  this 
> 'mybucketName.s3.amazonaws.com'
> Paperclip::Attachment.default_options[:path] = 
> '/:class/:attachment/:id_partition/:style/:filename'
> 
> my production.rb in config/environments this code at the end
> 
>  config.paperclip_defaults = {
>storage: :s3,
>s3_credentials: {
>  bucket: ENV.fetch('S3_BUCKET_NAME'),
>  access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'),
>  secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'),
>  s3_region: ENV.fetch('AWS_REGION'),
>}
>  }
> 
> My pin.rb in models has this code
> 
> Class Pin < ApplicationRecord
>   belongs_to :user
>   has_attached_file :image, styles: { medium: "300x300#", thumb: 
> "100x100>" }
>validates_attachment_content_type :image, content_type: /\Aimage\/.*\z/
> end
> 
> my index.html.erb to view my pins has this code
> 
> <%= render 'home/jumbo' unless user_signed_in? %>
> 
> <%= will_paginate @pins%>
> 
> 
>   <% @pins.each do |pin| %>   
>   
>  
>   <%= link_to image_tag(pin.image.url(:medium)),pin 
> %>
>   
>   <%= pin.description %>
>   <%= pin.user.name if pin.user 
> %>
> 
>   <%#= link_to 'Show', pin %>
>   <% if pin.user == current_user %>
>   
> <%= link_to 'Edit', edit_pin_path(pin) %>
> <%= link_to 'Destroy', pin, method: :delete, 
> data: { confirm: 'Are you sure?' } %>
>   
>   <% end %>   
>   
>   
>   <% end %>   
> 
> 
> What else am I missing to connect Heroku to AWS S3 Bucket to upload and store 
> images?
> 
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/0bc96cca-11e0-449a-9652-53a359bb799d%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
> 
> 
> -- 
> Dave Merrick
> 
> Daves Web Designs
> 
> Website http://www.daveswebdesigns.co.nz
> 
> Email merrick...@gmail.com
> 
> Ph   03 216 2053
> 
> Cell 027 3089 169
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/CA%2B%3DMcKby7nYRSK_3PMMki_qEYHvqc8PR17%3DvQVQiKgShZdeqMg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/865CEC38-F174-4E4E-81A9-17726AC8E87C%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] gsub global operator

2019-02-05 Thread Walter Lee Davis


> On Feb 5, 2019, at 3:34 AM, fugee ohu  wrote:
> 
> Does gsub have a global operator? How do I gsub in cases where there are 
> multiple  lines that need to be treated as a single string? 

What is the difference between sub() and gsub()?

https://docs.ruby-lang.org/en/2.3.0/String.html#method-i-sub
https://docs.ruby-lang.org/en/2.3.0/String.html#method-i-gsub

What makes you think that gsub needs any special hint to treat a multi-line 
string as a source of multiple matches? Show your work.

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+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/c9dcb4ae-c3fb-4932-868b-4a2390295327%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/93730F34-0223-4BD5-BD5A-BB6CB2DD1C79%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] text visible in browser but not in source

2019-02-04 Thread Walter Lee Davis


> On Feb 4, 2019, at 12:27 PM, fugee ohu  wrote:
> 
> 
> 
> On Monday, February 4, 2019 at 8:10:33 AM UTC-5, Walter Lee Davis wrote:
> 
> > On Feb 4, 2019, at 7:35 AM, fugee ohu  wrote: 
> > 
> > 
> > 
> > On Sunday, February 3, 2019 at 9:54:25 PM UTC-5, Walter Lee Davis wrote: 
> > 
> > > On Feb 3, 2019, at 7:14 PM, fugee ohu  wrote: 
> > > 
> > > 
> > > 
> > > On Wednesday, January 30, 2019 at 5:16:59 PM UTC-5, Colin Law wrote: 
> > > On Wed, 30 Jan 2019 at 22:12, Colin Law  wrote: 
> > > > 
> > > > On Wed, 30 Jan 2019 at 22:09, fugee ohu  wrote: 
> > > > > 
> > > > > 
> > > > > 
> > > > > On Wednesday, January 30, 2019 at 5:02:17 PM UTC-5, Colin Law wrote: 
> > > > >> 
> > > > >> On Wed, 30 Jan 2019 at 21:56, fugee ohu  wrote: 
> > > > >> > ... 
> > > > >> > Everything in the unparsed resonse body that I want is between [ 
> > > > >> > and ] I have to gsub it out 
> > > > >> 
> > > > >> 
> > > > >> No you don't.  After you get parsed_obj["results] (which is an 
> > > > >> array, 
> > > > >> that's what the [] mean) then you can get the first product by 
> > > > >> parsed_obj["results"][0]["productId"] 
> > > > >> It is just an array.  You have met ruby arrays haven't you? 
> > > > >> 
> > > > >> I am rapidly losing the will to live. 
> > > > >> 
> > > > >> Colin 
> > > > > 
> > > > > 
> > > > > The response body isn't JSON.parse parsable as is it has to be gsub'd 
> > > > > and chomped first before I can run JSON.parse My original gsub wasn't 
> > > > > right it wasn't removing the end that follows ] 
> > > > > JSON::ParserError: 784: unexpected token at 
> > > > > 'myscript.js({"success":true,"code 
> > > > 
> > > > You previously posted that you had got parsed_obj where 
> > > > parsed_obj["results]  was an array.  Go back to that. 
> > > 
> > > To quote your previous message 
> > > 
> > > >puts parsed_obj["results"]  shows the entire results but `puts 
> > > >parsed_obj["results"]["productId"] gets me error no implicit 
> > > > conversion of String into Integer 
> > > 
> > > The error is because it is an array, which is perfectly obvious if you 
> > > look at the unparsed string. So if you use 
> > > parsed_obj["results"][0] 
> > > you will get the first element 
> > > 
> > > Colin 
> > > 
> > > There are scripts in the browser page source that pass a lot of useful 
> > > values like this 
> > > 

Re: [Rails] text visible in browser but not in source

2019-02-04 Thread Walter Lee Davis


> On Feb 4, 2019, at 7:35 AM, fugee ohu  wrote:
> 
> 
> 
> On Sunday, February 3, 2019 at 9:54:25 PM UTC-5, Walter Lee Davis wrote:
> 
> > On Feb 3, 2019, at 7:14 PM, fugee ohu  wrote: 
> > 
> > 
> > 
> > On Wednesday, January 30, 2019 at 5:16:59 PM UTC-5, Colin Law wrote: 
> > On Wed, 30 Jan 2019 at 22:12, Colin Law  wrote: 
> > > 
> > > On Wed, 30 Jan 2019 at 22:09, fugee ohu  wrote: 
> > > > 
> > > > 
> > > > 
> > > > On Wednesday, January 30, 2019 at 5:02:17 PM UTC-5, Colin Law wrote: 
> > > >> 
> > > >> On Wed, 30 Jan 2019 at 21:56, fugee ohu  wrote: 
> > > >> > ... 
> > > >> > Everything in the unparsed resonse body that I want is between [ and 
> > > >> > ] I have to gsub it out 
> > > >> 
> > > >> 
> > > >> No you don't.  After you get parsed_obj["results] (which is an array, 
> > > >> that's what the [] mean) then you can get the first product by 
> > > >> parsed_obj["results"][0]["productId"] 
> > > >> It is just an array.  You have met ruby arrays haven't you? 
> > > >> 
> > > >> I am rapidly losing the will to live. 
> > > >> 
> > > >> Colin 
> > > > 
> > > > 
> > > > The response body isn't JSON.parse parsable as is it has to be gsub'd 
> > > > and chomped first before I can run JSON.parse My original gsub wasn't 
> > > > right it wasn't removing the end that follows ] 
> > > > JSON::ParserError: 784: unexpected token at 
> > > > 'myscript.js({"success":true,"code 
> > > 
> > > You previously posted that you had got parsed_obj where 
> > > parsed_obj["results]  was an array.  Go back to that. 
> > 
> > To quote your previous message 
> > 
> > >puts parsed_obj["results"]  shows the entire results but `puts 
> > >parsed_obj["results"]["productId"] gets me error no implicit 
> > > conversion of String into Integer 
> > 
> > The error is because it is an array, which is perfectly obvious if you 
> > look at the unparsed string. So if you use 
> > parsed_obj["results"][0] 
> > you will get the first element 
> > 
> > Colin 
> > 
> > There are scripts in the browser page source that pass a lot of useful 
> > values like this 
> > 

Re: [Rails] text visible in browser but not in source

2019-02-03 Thread Walter Lee Davis


> On Feb 3, 2019, at 7:14 PM, fugee ohu  wrote:
> 
> 
> 
> On Wednesday, January 30, 2019 at 5:16:59 PM UTC-5, Colin Law wrote:
> On Wed, 30 Jan 2019 at 22:12, Colin Law  wrote: 
> > 
> > On Wed, 30 Jan 2019 at 22:09, fugee ohu  wrote: 
> > > 
> > > 
> > > 
> > > On Wednesday, January 30, 2019 at 5:02:17 PM UTC-5, Colin Law wrote: 
> > >> 
> > >> On Wed, 30 Jan 2019 at 21:56, fugee ohu  wrote: 
> > >> > ... 
> > >> > Everything in the unparsed resonse body that I want is between [ and ] 
> > >> > I have to gsub it out 
> > >> 
> > >> 
> > >> No you don't.  After you get parsed_obj["results] (which is an array, 
> > >> that's what the [] mean) then you can get the first product by 
> > >> parsed_obj["results"][0]["productId"] 
> > >> It is just an array.  You have met ruby arrays haven't you? 
> > >> 
> > >> I am rapidly losing the will to live. 
> > >> 
> > >> Colin 
> > > 
> > > 
> > > The response body isn't JSON.parse parsable as is it has to be gsub'd and 
> > > chomped first before I can run JSON.parse My original gsub wasn't right 
> > > it wasn't removing the end that follows ] 
> > > JSON::ParserError: 784: unexpected token at 
> > > 'myscript.js({"success":true,"code 
> > 
> > You previously posted that you had got parsed_obj where 
> > parsed_obj["results]  was an array.  Go back to that. 
> 
> To quote your previous message 
> 
> >puts parsed_obj["results"]  shows the entire results but `puts 
> >parsed_obj["results"]["productId"] gets me error no implicit 
> > conversion of String into Integer 
> 
> The error is because it is an array, which is perfectly obvious if you 
> look at the unparsed string. So if you use 
> parsed_obj["results"][0] 
> you will get the first element 
> 
> Colin 
> 
> There are scripts in the browser page source that pass a lot of useful values 
> like this
> 

Re: [Rails] update rails version from 2.x to 5.x in an existing very old rails application

2019-02-01 Thread Walter Lee Davis


> On Feb 1, 2019, at 3:17 AM, Phil Edelbrock  wrote:
> 
> 
>> On Feb 1, 2019, at 12:02 AM, Hasan Diwan  wrote:
>> 
>> To be safe, go through a stepwise upgrade, running and fixing your tests at 
>> each step. -- H
>> 
>> 
>> On Thu, 31 Jan 2019 at 23:50, raj kumar <2017k...@gmail.com> wrote:
>> I have a Rails app, made 10 years back in 2009 with following version:
>> rails version = 2.0.2 
>> ruby version = 1.8.7
>> Database = PostgreSQL
>> 
>> Now what steps I should adopt in order to upgrade it to latest version of 
>> ruby and rails i.e.,
>> rails version = 5.2
>> ruby version = 2.6
>> Database = PostgreSQL
>> 
>> As per up-gradation rule 
>> here(https://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html), I 
>> need to start up-gradation one by one version gradually like,
>> 2.x to 3.x
>> 3.x to 4.x 
>> 4.x to 5.x
>> 
>> My question here is, 
>> Is there any other way to directly update it from 2.x to 5.x?
>> 
>> Note: I can develop it by scratch but my client not agree on that, they just 
>> asking for update in existing app not build from scratch in latest version 
>> of Ruby on Rails.
>> 
>> Kindly provide your thoughts.
>> 
>> Thanks 
> 
> Good advise by Hasan.  If the project isn't that complex, though, you could 
> just jump to the latest.. .sometimes rewriting incrementally can be a painful 
> waste of time just to rewrite again as you go from each increment to the next.
> 
> Latest Ruby should be the least of your problems... you will get huge code 
> speedups from nothing more than upgrading Ruby.  Most of the changes to Ruby 
> since 1.8/1.9 to 2.6 have been to garbage collection speedups.
> 
> ActiveRecord changes and routes might be your most significant rewrites.  
> Because we're looking at Rails 6 beta as the current, you could also leapfrog 
> to that?  (depending on your scheduling and policies on using betas)
> 
> Good luck!
> 
> 
> Phil
> 

I'll second the idea to rebuild. One of the problems you'll run into is finding 
authoritative documentation for all the little things you'll need to do to go 
just from 2.0.2 to 2.3.1 (the last stable 2 branch, IIRC). Then rinse and 
repeat when you go to 3.0.x etc. That many jumps can easily swamp the amount of 
time it would take to just rebuild.

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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/7CD6F56E-5F92-4475-8657-ABF01598BF6E%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] can i perform validations on an uploader mounted column

2019-01-31 Thread Walter Lee Davis


> On Jan 31, 2019, at 4:57 PM, fugee ohu  wrote:
> 
> 
> 
> On Thursday, January 31, 2019 at 4:38:52 PM UTC-5, Walter Lee Davis wrote:
> 
> > On Jan 31, 2019, at 3:50 PM, fugee ohu  wrote: 
> > 
> > I had to remove a validation on the :name column because my PictureUploader 
> > which uses Carrierwave is mounted on that column 
> >  mount_uploader :name, PictureUploader 
> > This causes validation 
> > validates :name, presence: true 
> > to cause rows in pictures to be invalid for blank :name even though the 
> > name, just a filename, is in the database for that column 
> 
> CarrierWave overloads the accessor for the attachment column to respond with 
> the entire uploader model object. This is normal for CarrierWave. 
> 
> There are other attachment systems (I'm fond of Shrine) that use a different, 
> less-surprising approach. In Shrine, you would have a column called 
> picture_data and an attachment called picture. That way you can keep the 
> difference between db column and virtual object separate. 
> 
> 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-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/8f78599a-5e59-43e1-8d1e-ec38e897c68d%40googlegroups.com.
> >  
> > For more options, visit https://groups.google.com/d/optout. 
> 
>  If the uploader's mounted on that column do I still have to validate it ?
> 

I haven't used Carrierwave in a number of years, but I think that it implements 
some validators of its own. You should investigate the documentation for CW.

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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/B29EF39A-C1C0-4170-9D26-0D58EE445931%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] can i perform validations on an uploader mounted column

2019-01-31 Thread Walter Lee Davis


> On Jan 31, 2019, at 3:50 PM, fugee ohu  wrote:
> 
> I had to remove a validation on the :name column because my PictureUploader 
> which uses Carrierwave is mounted on that column
>  mount_uploader :name, PictureUploader
> This causes validation
> validates :name, presence: true
> to cause rows in pictures to be invalid for blank :name even though the name, 
> just a filename, is in the database for that column

CarrierWave overloads the accessor for the attachment column to respond with 
the entire uploader model object. This is normal for CarrierWave.

There are other attachment systems (I'm fond of Shrine) that use a different, 
less-surprising approach. In Shrine, you would have a column called 
picture_data and an attachment called picture. That way you can keep the 
difference between db column and virtual object separate.

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+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/8f78599a-5e59-43e1-8d1e-ec38e897c68d%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/6A2E2DCB-4B5C-465A-9952-1E37FC4370D7%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] url slugs with special characters

2019-01-29 Thread Walter Lee Davis


> On Jan 29, 2019, at 9:55 PM, fugee ohu  wrote:
> 
> 
> 
> On Tuesday, January 29, 2019 at 8:31:18 AM UTC-5, Walter Lee Davis wrote:
> 
> > On Jan 28, 2019, at 8:47 PM, fugee ohu  wrote: 
> > 
> > 
> > 
> > On Monday, January 28, 2019 at 10:23:43 AM UTC-5, Walter Lee Davis wrote: 
> > 
> > > On Jan 27, 2019, at 8:34 PM, fugee ohu  wrote: 
> > > 
> > > 
> > > 
> > > On Sunday, January 27, 2019 at 5:31:11 PM UTC-5, Walter Lee Davis wrote: 
> > > 
> > > > On Jan 27, 2019, at 5:01 PM, fugee ohu  wrote: 
> > > > 
> > > > 
> > > > 
> > > > On Sunday, January 27, 2019 at 4:47:48 PM UTC-5, Walter Lee Davis 
> > > > wrote: 
> > > > 
> > > > > On Jan 27, 2019, at 4:11 PM, fugee ohu  wrote: 
> > > > > 
> > > > > 
> > > > > 
> > > > > On Sunday, January 27, 2019 at 2:43:46 PM UTC-5, Walter Lee Davis 
> > > > > wrote: 
> > > > > 
> > > > > > On Jan 27, 2019, at 7:35 AM, fugee ohu  wrote: 
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > On Sunday, January 27, 2019 at 12:24:25 AM UTC-5, Walter Lee Davis 
> > > > > > wrote: 
> > > > > > 
> > > > > > > On Jan 26, 2019, at 11:49 PM, fugee ohu  
> > > > > > > wrote: 
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > On Saturday, January 26, 2019 at 6:58:17 PM UTC-5, Walter Lee 
> > > > > > > Davis wrote: 
> > > > > > > 
> > > > > > > > On Jan 26, 2019, at 5:27 PM, fugee ohu  
> > > > > > > > wrote: 
> > > > > > > > 
> > > > > > > > TypeError: no implicit conversion of Symbol into Integer 
> > > > > > > > from app/models/press_release.rb:17:in `truncated_headline' 
> > > > > > > > 
> > > > > > > > 
> > > > > > > > class PressRelease < ApplicationRecord 
> > > > > > > > 
> > > > > > > >   extend FriendlyId 
> > > > > > > >   friendly_id :truncated_headline, use: :slugged 
> > > > > > > > 
> > > > > > > >   
> > > > > > > >   def truncated_headline 
> > > > > > > >   # cut off at 200 characters, without an ellipsis 
> > > > > > > > headline.truncate(255, '') 
> > > > > > > >   end 
> > > > > > > > 
> > > > > > > 
> > > > > > > Aha. truncate takes named arguments past the first one. The 
> > > > > > > correct signature is 
> > > > > > > 
> > > > > > > headline.truncate(255, omission: '') 
> > > > > > > 
> > > > > > > This should work. 
> > > > > > > 
> > > > > > > Walter 
> > > > > > > 
> > > > > > > Still rolling back 
> > > > > > > 
> > > > > > > 
> > > > > > 
> > > > > > Show me an example from your development console. Copy and paste. 
> > > > > > Make sure that you include the part where we can see the parameters 
> > > > > > being passed into your controller. I suspect that you are trying to 
> > > > > > pass a type = 'admin' parameter somewhere, that's what the error 
> > > > > > looked like earlier. Type columns in polymorphic relationships must 
> > > > > > be passed a valid constant name, which will begin with an 
> > > > > > upper-case letter. If there is a model in that relationship named 
> > > > > > admin, you would pass Admin rather than admin. 
> > > > > > 
> > > > > > Walter 
> > > > > > 
> > > > > > 
> > > > > >  Loading development environment (Rails 5.2.0) 
> > > > > > 2.3.3 :001 > PressRelease.find_each(&:save) 
> > > > > >   Query Trace > (irb):1:in `irb_binding' 
> > > > > >(24.1ms)  SET NAMES utf8,  @@SESSION.sql_mode = 
> > > > > > CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), 
> > > > > > ',NO_A

Re: [Rails] url slugs with special characters

2019-01-29 Thread Walter Lee Davis


> On Jan 28, 2019, at 8:47 PM, fugee ohu  wrote:
> 
> 
> 
> On Monday, January 28, 2019 at 10:23:43 AM UTC-5, Walter Lee Davis wrote:
> 
> > On Jan 27, 2019, at 8:34 PM, fugee ohu  wrote: 
> > 
> > 
> > 
> > On Sunday, January 27, 2019 at 5:31:11 PM UTC-5, Walter Lee Davis wrote: 
> > 
> > > On Jan 27, 2019, at 5:01 PM, fugee ohu  wrote: 
> > > 
> > > 
> > > 
> > > On Sunday, January 27, 2019 at 4:47:48 PM UTC-5, Walter Lee Davis wrote: 
> > > 
> > > > On Jan 27, 2019, at 4:11 PM, fugee ohu  wrote: 
> > > > 
> > > > 
> > > > 
> > > > On Sunday, January 27, 2019 at 2:43:46 PM UTC-5, Walter Lee Davis 
> > > > wrote: 
> > > > 
> > > > > On Jan 27, 2019, at 7:35 AM, fugee ohu  wrote: 
> > > > > 
> > > > > 
> > > > > 
> > > > > On Sunday, January 27, 2019 at 12:24:25 AM UTC-5, Walter Lee Davis 
> > > > > wrote: 
> > > > > 
> > > > > > On Jan 26, 2019, at 11:49 PM, fugee ohu  wrote: 
> > > > > > 
> > > > > > 
> > > > > > 
> > > > > > On Saturday, January 26, 2019 at 6:58:17 PM UTC-5, Walter Lee Davis 
> > > > > > wrote: 
> > > > > > 
> > > > > > > On Jan 26, 2019, at 5:27 PM, fugee ohu  wrote: 
> > > > > > > 
> > > > > > > TypeError: no implicit conversion of Symbol into Integer 
> > > > > > > from app/models/press_release.rb:17:in `truncated_headline' 
> > > > > > > 
> > > > > > > 
> > > > > > > class PressRelease < ApplicationRecord 
> > > > > > > 
> > > > > > >   extend FriendlyId 
> > > > > > >   friendly_id :truncated_headline, use: :slugged 
> > > > > > > 
> > > > > > >   
> > > > > > >   def truncated_headline 
> > > > > > >   # cut off at 200 characters, without an ellipsis 
> > > > > > > headline.truncate(255, '') 
> > > > > > >   end 
> > > > > > > 
> > > > > > 
> > > > > > Aha. truncate takes named arguments past the first one. The correct 
> > > > > > signature is 
> > > > > > 
> > > > > > headline.truncate(255, omission: '') 
> > > > > > 
> > > > > > This should work. 
> > > > > > 
> > > > > > Walter 
> > > > > > 
> > > > > > Still rolling back 
> > > > > > 
> > > > > > 
> > > > > 
> > > > > Show me an example from your development console. Copy and paste. 
> > > > > Make sure that you include the part where we can see the parameters 
> > > > > being passed into your controller. I suspect that you are trying to 
> > > > > pass a type = 'admin' parameter somewhere, that's what the error 
> > > > > looked like earlier. Type columns in polymorphic relationships must 
> > > > > be passed a valid constant name, which will begin with an upper-case 
> > > > > letter. If there is a model in that relationship named admin, you 
> > > > > would pass Admin rather than admin. 
> > > > > 
> > > > > Walter 
> > > > > 
> > > > > 
> > > > >  Loading development environment (Rails 5.2.0) 
> > > > > 2.3.3 :001 > PressRelease.find_each(&:save) 
> > > > >   Query Trace > (irb):1:in `irb_binding' 
> > > > >(24.1ms)  SET NAMES utf8,  @@SESSION.sql_mode = 
> > > > > CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), 
> > > > > ',NO_AUTO_VALUE_ON_ZERO'),  @@SESSION.sql_auto_is_null = 0, 
> > > > > @@SESSION.wait_timeout = 2147483 
> > > > >   Query Trace > (irb):1:in `irb_binding' 
> > > > >   PressRelease Load (53.8ms)  SELECT  `press_releases`.* FROM 
> > > > > `press_releases` ORDER BY `press_releases`.`id` ASC LIMIT 1000 
> > > > >   Query Trace > (irb):1:in `irb_binding' 
> > > > >(7.1ms)  BEGIN 
> > > > >   Query Trace > (irb):1:in `irb_binding' 
> > > > >   PressRelease Exists (9.4ms)  SELECT  1 AS one FROM `press_releases` 
> > > > > WHERE `press_r

Re: [Rails] How do I update someone else's fork?

2019-01-28 Thread Walter Lee Davis
Ask the submitter to pull master back into their branch, and push again. That 
will bring it back together, and will also put the burden of resolving any 
conflicts between their branch and the rest of the project.

Walter

> On Jan 28, 2019, at 5:59 PM, Jason Hsu  wrote:
> 
> I'm on the RailsBridge Bridge Troll project at 
> https://github.com/railsbridge/bridge_troll.  I am NOT a collaborator.  My 
> fork is at https://github.com/jhsu802701/bridge_troll.
> 
> Someone else submitted a pull request that is now lagging several commits 
> behind the upstream master branch.  This pull request is at 
> https://github.com/railsbridge/bridge_troll/pull/580.
> 
> How do I sync up the branch behind this pull request?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/a571effe-1895-45cf-805a-cd07ff541f0a%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/93277661-94D3-43F4-82AD-C5416C7FAD6A%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] AWS and hosting a Website

2019-01-28 Thread Walter Lee Davis


> On Jan 28, 2019, at 3:18 PM, David Merrick  wrote:
> 
> Yes I have EC2 instance but its on Cloud9

Aha. That's like having a cloud server for your development environment. That 
makes sense, then, that it would stop running when you stop working in its 
console. It's like spinning up rails server in the console on your Mac.

Now you need to do something similar, but with a production environment. 

The web is awash in tutorials that will explain how to deploy a production 
instance of your Rails application on any number of different hosting 
platforms. Heroku is certainly a good choice, because it exchanges you 
following a set of conventions and and accepting some restrictions (and paying 
for the pleasure) for seriously no-pain deployment. Amazon has their Elastic 
Beanstalk service, which does something similar (I think, never tried it).

But you can use EC2  to set up a virtual private server. To do that, you have 
to know a fair number of details about running a Linux server, since what you 
get in EC2 (without another layer over the top of it) is literally near-root 
(sudo) access to a bare system install Linux box. Everything you want to add 
(web server, application server, ruby itself, etc.) will be put there by your 
own hand. 

Be ready to use `apt-get install each individual thing` and a fair amount of 
configuration (generating and installing a certificate and setting up SSL, for 
example) before anyone can find your site and use it. 

But once you do, you'll have a server running an application server like 
Passenger or Unicorn (which will handle scaling and restarting your app) and a 
web server like Apache 2 or NGINX to proxy requests to it. And all of that will 
start up whenever your virtual machine restarts, and that will only be because 
you asked it to manually, or something catastrophic happened (like Netflix and 
half the internet is down).

Walter

> 
> On Tue, Jan 29, 2019 at 5:15 AM Hassan Schroeder  
> wrote:
> On Sun, Jan 27, 2019 at 12:33 PM David Merrick  wrote:
> 
> > I would like to know how to do
> > + Is your system configured to monitor your app and restart it when it 
> > crashes?
> > + Is your system configured to notify you when it can't reliably
> > restart a crashed app?
> > + Do you have monitoring in place to notify you when your app's unreachable?
> 
> Too broad to answer. It depends on the server OS, how you've set
> up Rails (web server, app server), budget, etc. etc.
> 
> Do you have a current running EC2 instance, or is this brand new?
> 
> -- 
> Hassan Schroeder  hassan.schroe...@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+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yDgbjbjpPFBeJnQV3MRpQToLTqZ9jenH%2BQtyNswxiA1JA%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
> 
> 
> -- 
> Dave Merrick
> 
> Daves Web Designs
> 
> Website http://www.daveswebdesigns.co.nz
> 
> Email merrick...@gmail.com
> 
> Ph   03 216 2053
> 
> Cell 027 3089 169
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/CA%2B%3DMcKZU%3DQyg5YoeJhVrMJXzS_zJ2kQ473q-jLBzFdvLZtvzDw%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/66FAC48E-14C7-45A7-B2AE-0EEF530419A7%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] url slugs with special characters

2019-01-28 Thread Walter Lee Davis


> On Jan 27, 2019, at 8:34 PM, fugee ohu  wrote:
> 
> 
> 
> On Sunday, January 27, 2019 at 5:31:11 PM UTC-5, Walter Lee Davis wrote:
> 
> > On Jan 27, 2019, at 5:01 PM, fugee ohu  wrote: 
> > 
> > 
> > 
> > On Sunday, January 27, 2019 at 4:47:48 PM UTC-5, Walter Lee Davis wrote: 
> > 
> > > On Jan 27, 2019, at 4:11 PM, fugee ohu  wrote: 
> > > 
> > > 
> > > 
> > > On Sunday, January 27, 2019 at 2:43:46 PM UTC-5, Walter Lee Davis wrote: 
> > > 
> > > > On Jan 27, 2019, at 7:35 AM, fugee ohu  wrote: 
> > > > 
> > > > 
> > > > 
> > > > On Sunday, January 27, 2019 at 12:24:25 AM UTC-5, Walter Lee Davis 
> > > > wrote: 
> > > > 
> > > > > On Jan 26, 2019, at 11:49 PM, fugee ohu  wrote: 
> > > > > 
> > > > > 
> > > > > 
> > > > > On Saturday, January 26, 2019 at 6:58:17 PM UTC-5, Walter Lee Davis 
> > > > > wrote: 
> > > > > 
> > > > > > On Jan 26, 2019, at 5:27 PM, fugee ohu  wrote: 
> > > > > > 
> > > > > > TypeError: no implicit conversion of Symbol into Integer 
> > > > > > from app/models/press_release.rb:17:in `truncated_headline' 
> > > > > > 
> > > > > > 
> > > > > > class PressRelease < ApplicationRecord 
> > > > > > 
> > > > > >   extend FriendlyId 
> > > > > >   friendly_id :truncated_headline, use: :slugged 
> > > > > > 
> > > > > >   
> > > > > >   def truncated_headline 
> > > > > >   # cut off at 200 characters, without an ellipsis 
> > > > > > headline.truncate(255, '') 
> > > > > >   end 
> > > > > > 
> > > > > 
> > > > > Aha. truncate takes named arguments past the first one. The correct 
> > > > > signature is 
> > > > > 
> > > > > headline.truncate(255, omission: '') 
> > > > > 
> > > > > This should work. 
> > > > > 
> > > > > Walter 
> > > > > 
> > > > > Still rolling back 
> > > > > 
> > > > > 
> > > > 
> > > > Show me an example from your development console. Copy and paste. Make 
> > > > sure that you include the part where we can see the parameters being 
> > > > passed into your controller. I suspect that you are trying to pass a 
> > > > type = 'admin' parameter somewhere, that's what the error looked like 
> > > > earlier. Type columns in polymorphic relationships must be passed a 
> > > > valid constant name, which will begin with an upper-case letter. If 
> > > > there is a model in that relationship named admin, you would pass Admin 
> > > > rather than admin. 
> > > > 
> > > > Walter 
> > > > 
> > > > 
> > > >  Loading development environment (Rails 5.2.0) 
> > > > 2.3.3 :001 > PressRelease.find_each(&:save) 
> > > >   Query Trace > (irb):1:in `irb_binding' 
> > > >(24.1ms)  SET NAMES utf8,  @@SESSION.sql_mode = 
> > > > CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), 
> > > > ',NO_AUTO_VALUE_ON_ZERO'),  @@SESSION.sql_auto_is_null = 0, 
> > > > @@SESSION.wait_timeout = 2147483 
> > > >   Query Trace > (irb):1:in `irb_binding' 
> > > >   PressRelease Load (53.8ms)  SELECT  `press_releases`.* FROM 
> > > > `press_releases` ORDER BY `press_releases`.`id` ASC LIMIT 1000 
> > > >   Query Trace > (irb):1:in `irb_binding' 
> > > >(7.1ms)  BEGIN 
> > > >   Query Trace > (irb):1:in `irb_binding' 
> > > >   PressRelease Exists (9.4ms)  SELECT  1 AS one FROM `press_releases` 
> > > > WHERE `press_releases`.`id` != 2 AND `press_releases`.`slug` = 
> > > > 'outskirts-of-love-is-available-now-some-autographed-copies-remain' 
> > > > LIMIT 1 
> > > >   Query Trace > (irb):1:in `irb_binding' 
> > > >(7.9ms)  ROLLBACK 
> > > >   Query Trace > (irb):1:in `irb_binding' 
> > > >(5.6ms)  BEGIN 
> > > >   Query Trace > (irb):1:in `irb_binding' 
> > > >   PressRelease Exists (9.6ms)  SELECT  1 AS one FROM `press_releases` 
> > > > WHERE `press_releases`.`id` != 3 AND `press_releases`.`slug` 

Re: [Rails] url slugs with special characters

2019-01-27 Thread Walter Lee Davis


> On Jan 27, 2019, at 5:01 PM, fugee ohu  wrote:
> 
> 
> 
> On Sunday, January 27, 2019 at 4:47:48 PM UTC-5, Walter Lee Davis wrote:
> 
> > On Jan 27, 2019, at 4:11 PM, fugee ohu  wrote: 
> > 
> > 
> > 
> > On Sunday, January 27, 2019 at 2:43:46 PM UTC-5, Walter Lee Davis wrote: 
> > 
> > > On Jan 27, 2019, at 7:35 AM, fugee ohu  wrote: 
> > > 
> > > 
> > > 
> > > On Sunday, January 27, 2019 at 12:24:25 AM UTC-5, Walter Lee Davis wrote: 
> > > 
> > > > On Jan 26, 2019, at 11:49 PM, fugee ohu  wrote: 
> > > > 
> > > > 
> > > > 
> > > > On Saturday, January 26, 2019 at 6:58:17 PM UTC-5, Walter Lee Davis 
> > > > wrote: 
> > > > 
> > > > > On Jan 26, 2019, at 5:27 PM, fugee ohu  wrote: 
> > > > > 
> > > > > TypeError: no implicit conversion of Symbol into Integer 
> > > > > from app/models/press_release.rb:17:in `truncated_headline' 
> > > > > 
> > > > > 
> > > > > class PressRelease < ApplicationRecord 
> > > > > 
> > > > >   extend FriendlyId 
> > > > >   friendly_id :truncated_headline, use: :slugged 
> > > > > 
> > > > >   
> > > > >   def truncated_headline 
> > > > >   # cut off at 200 characters, without an ellipsis 
> > > > > headline.truncate(255, '') 
> > > > >   end 
> > > > > 
> > > > 
> > > > Aha. truncate takes named arguments past the first one. The correct 
> > > > signature is 
> > > > 
> > > > headline.truncate(255, omission: '') 
> > > > 
> > > > This should work. 
> > > > 
> > > > Walter 
> > > > 
> > > > Still rolling back 
> > > > 
> > > > 
> > > 
> > > Show me an example from your development console. Copy and paste. Make 
> > > sure that you include the part where we can see the parameters being 
> > > passed into your controller. I suspect that you are trying to pass a type 
> > > = 'admin' parameter somewhere, that's what the error looked like earlier. 
> > > Type columns in polymorphic relationships must be passed a valid constant 
> > > name, which will begin with an upper-case letter. If there is a model in 
> > > that relationship named admin, you would pass Admin rather than admin. 
> > > 
> > > Walter 
> > > 
> > > 
> > >  Loading development environment (Rails 5.2.0) 
> > > 2.3.3 :001 > PressRelease.find_each(&:save) 
> > >   Query Trace > (irb):1:in `irb_binding' 
> > >(24.1ms)  SET NAMES utf8,  @@SESSION.sql_mode = 
> > > CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), 
> > > ',NO_AUTO_VALUE_ON_ZERO'),  @@SESSION.sql_auto_is_null = 0, 
> > > @@SESSION.wait_timeout = 2147483 
> > >   Query Trace > (irb):1:in `irb_binding' 
> > >   PressRelease Load (53.8ms)  SELECT  `press_releases`.* FROM 
> > > `press_releases` ORDER BY `press_releases`.`id` ASC LIMIT 1000 
> > >   Query Trace > (irb):1:in `irb_binding' 
> > >(7.1ms)  BEGIN 
> > >   Query Trace > (irb):1:in `irb_binding' 
> > >   PressRelease Exists (9.4ms)  SELECT  1 AS one FROM `press_releases` 
> > > WHERE `press_releases`.`id` != 2 AND `press_releases`.`slug` = 
> > > 'outskirts-of-love-is-available-now-some-autographed-copies-remain' LIMIT 
> > > 1 
> > >   Query Trace > (irb):1:in `irb_binding' 
> > >(7.9ms)  ROLLBACK 
> > >   Query Trace > (irb):1:in `irb_binding' 
> > >(5.6ms)  BEGIN 
> > >   Query Trace > (irb):1:in `irb_binding' 
> > >   PressRelease Exists (9.6ms)  SELECT  1 AS one FROM `press_releases` 
> > > WHERE `press_releases`.`id` != 3 AND `press_releases`.`slug` = 
> > > 'shemekia-copeland-to-appear-in-new-york-and-teaneck' LIMIT 1 
> > >   Query Trace > (irb):1:in `irb_binding' 
> > >(6.3ms)  ROLLBACK 
> > >   Query Trace > (irb):1:in `irb_binding' 
> > >(6.0ms)  BEGIN 
> > >   Query Trace > (irb):1:in `irb_binding' 
> > >   PressRelease Exists (12.7ms)  SELECT  1 AS one FROM `press_releases` 
> > > WHERE `press_releases`.`id` != 5 AND `press_releases`.`slug` = 
> > > 'al-basile-creates-new-roots-music-masterpiece-with-b-s-expression-due-september-18-on-sweetspot-records-latest-release-is-most-fully-realized-album-ye

Re: [Rails] url slugs with special characters

2019-01-27 Thread Walter Lee Davis


> On Jan 27, 2019, at 4:11 PM, fugee ohu  wrote:
> 
> 
> 
> On Sunday, January 27, 2019 at 2:43:46 PM UTC-5, Walter Lee Davis wrote:
> 
> > On Jan 27, 2019, at 7:35 AM, fugee ohu  wrote: 
> > 
> > 
> > 
> > On Sunday, January 27, 2019 at 12:24:25 AM UTC-5, Walter Lee Davis wrote: 
> > 
> > > On Jan 26, 2019, at 11:49 PM, fugee ohu  wrote: 
> > > 
> > > 
> > > 
> > > On Saturday, January 26, 2019 at 6:58:17 PM UTC-5, Walter Lee Davis 
> > > wrote: 
> > > 
> > > > On Jan 26, 2019, at 5:27 PM, fugee ohu  wrote: 
> > > > 
> > > > TypeError: no implicit conversion of Symbol into Integer 
> > > > from app/models/press_release.rb:17:in `truncated_headline' 
> > > > 
> > > > 
> > > > class PressRelease < ApplicationRecord 
> > > > 
> > > >   extend FriendlyId 
> > > >   friendly_id :truncated_headline, use: :slugged 
> > > > 
> > > >   
> > > >   def truncated_headline 
> > > >   # cut off at 200 characters, without an ellipsis 
> > > > headline.truncate(255, '') 
> > > >   end 
> > > > 
> > > 
> > > Aha. truncate takes named arguments past the first one. The correct 
> > > signature is 
> > > 
> > > headline.truncate(255, omission: '') 
> > > 
> > > This should work. 
> > > 
> > > Walter 
> > > 
> > > Still rolling back 
> > > 
> > > 
> > 
> > Show me an example from your development console. Copy and paste. Make sure 
> > that you include the part where we can see the parameters being passed into 
> > your controller. I suspect that you are trying to pass a type = 'admin' 
> > parameter somewhere, that's what the error looked like earlier. Type 
> > columns in polymorphic relationships must be passed a valid constant name, 
> > which will begin with an upper-case letter. If there is a model in that 
> > relationship named admin, you would pass Admin rather than admin. 
> > 
> > Walter 
> > 
> > 
> >  Loading development environment (Rails 5.2.0) 
> > 2.3.3 :001 > PressRelease.find_each(&:save) 
> >   Query Trace > (irb):1:in `irb_binding' 
> >(24.1ms)  SET NAMES utf8,  @@SESSION.sql_mode = 
> > CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), 
> >  @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483 
> >   Query Trace > (irb):1:in `irb_binding' 
> >   PressRelease Load (53.8ms)  SELECT  `press_releases`.* FROM 
> > `press_releases` ORDER BY `press_releases`.`id` ASC LIMIT 1000 
> >   Query Trace > (irb):1:in `irb_binding' 
> >(7.1ms)  BEGIN 
> >   Query Trace > (irb):1:in `irb_binding' 
> >   PressRelease Exists (9.4ms)  SELECT  1 AS one FROM `press_releases` WHERE 
> > `press_releases`.`id` != 2 AND `press_releases`.`slug` = 
> > 'outskirts-of-love-is-available-now-some-autographed-copies-remain' LIMIT 1 
> >   Query Trace > (irb):1:in `irb_binding' 
> >(7.9ms)  ROLLBACK 
> >   Query Trace > (irb):1:in `irb_binding' 
> >(5.6ms)  BEGIN 
> >   Query Trace > (irb):1:in `irb_binding' 
> >   PressRelease Exists (9.6ms)  SELECT  1 AS one FROM `press_releases` WHERE 
> > `press_releases`.`id` != 3 AND `press_releases`.`slug` = 
> > 'shemekia-copeland-to-appear-in-new-york-and-teaneck' LIMIT 1 
> >   Query Trace > (irb):1:in `irb_binding' 
> >(6.3ms)  ROLLBACK 
> >   Query Trace > (irb):1:in `irb_binding' 
> >(6.0ms)  BEGIN 
> >   Query Trace > (irb):1:in `irb_binding' 
> >   PressRelease Exists (12.7ms)  SELECT  1 AS one FROM `press_releases` 
> > WHERE `press_releases`.`id` != 5 AND `press_releases`.`slug` = 
> > 'al-basile-creates-new-roots-music-masterpiece-with-b-s-expression-due-september-18-on-sweetspot-records-latest-release-is-most-fully-realized-album-yet'
> >  LIMIT 1 
> >   Query Trace > (irb):1:in `irb_binding' 
> >(8.1ms)  ROLLBACK 
> >   Query Trace > (irb):1:in `irb_binding' 
> >(6.0ms)  BEGIN 
> >   Query Trace > (irb):1:in `irb_binding' 
> >   PressRelease Exists (8.9ms)  SELECT  1 AS one FROM `press_releases` WHERE 
> > `press_releases`.`id` != 6 AND `press_releases`.`slug` = 
> > 'new-cd-from-british-blues-godfather-john-mayall-find-a-way-to-care-set-for-release-september-4th-on-forty-below-records-vinyl-lp-to-follow-in-fall'
> >  LIMIT 1 
> >   Query Trace > (irb):1:in `irb_binding' 
> >(6.8ms)  R

Re: [Rails] url slugs with special characters

2019-01-27 Thread Walter Lee Davis


> On Jan 27, 2019, at 7:35 AM, fugee ohu  wrote:
> 
> 
> 
> On Sunday, January 27, 2019 at 12:24:25 AM UTC-5, Walter Lee Davis wrote:
> 
> > On Jan 26, 2019, at 11:49 PM, fugee ohu  wrote: 
> > 
> > 
> > 
> > On Saturday, January 26, 2019 at 6:58:17 PM UTC-5, Walter Lee Davis wrote: 
> > 
> > > On Jan 26, 2019, at 5:27 PM, fugee ohu  wrote: 
> > > 
> > > TypeError: no implicit conversion of Symbol into Integer 
> > > from app/models/press_release.rb:17:in `truncated_headline' 
> > > 
> > > 
> > > class PressRelease < ApplicationRecord 
> > > 
> > >   extend FriendlyId 
> > >   friendly_id :truncated_headline, use: :slugged 
> > > 
> > >   
> > >   def truncated_headline 
> > >   # cut off at 200 characters, without an ellipsis 
> > > headline.truncate(255, '') 
> > >   end 
> > > 
> > 
> > Aha. truncate takes named arguments past the first one. The correct 
> > signature is 
> > 
> > headline.truncate(255, omission: '') 
> > 
> > This should work. 
> > 
> > Walter 
> > 
> > Still rolling back 
> > 
> > 
> 
> Show me an example from your development console. Copy and paste. Make sure 
> that you include the part where we can see the parameters being passed into 
> your controller. I suspect that you are trying to pass a type = 'admin' 
> parameter somewhere, that's what the error looked like earlier. Type columns 
> in polymorphic relationships must be passed a valid constant name, which will 
> begin with an upper-case letter. If there is a model in that relationship 
> named admin, you would pass Admin rather than admin. 
> 
> Walter 
> 
> 
>  Loading development environment (Rails 5.2.0)
> 2.3.3 :001 > PressRelease.find_each(&:save)
>   Query Trace > (irb):1:in `irb_binding'
>(24.1ms)  SET NAMES utf8,  @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, 
> ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'),  @@SESSION.sql_auto_is_null 
> = 0, @@SESSION.wait_timeout = 2147483
>   Query Trace > (irb):1:in `irb_binding'
>   PressRelease Load (53.8ms)  SELECT  `press_releases`.* FROM 
> `press_releases` ORDER BY `press_releases`.`id` ASC LIMIT 1000
>   Query Trace > (irb):1:in `irb_binding'
>(7.1ms)  BEGIN
>   Query Trace > (irb):1:in `irb_binding'
>   PressRelease Exists (9.4ms)  SELECT  1 AS one FROM `press_releases` WHERE 
> `press_releases`.`id` != 2 AND `press_releases`.`slug` = 
> 'outskirts-of-love-is-available-now-some-autographed-copies-remain' LIMIT 1
>   Query Trace > (irb):1:in `irb_binding'
>(7.9ms)  ROLLBACK
>   Query Trace > (irb):1:in `irb_binding'
>(5.6ms)  BEGIN
>   Query Trace > (irb):1:in `irb_binding'
>   PressRelease Exists (9.6ms)  SELECT  1 AS one FROM `press_releases` WHERE 
> `press_releases`.`id` != 3 AND `press_releases`.`slug` = 
> 'shemekia-copeland-to-appear-in-new-york-and-teaneck' LIMIT 1
>   Query Trace > (irb):1:in `irb_binding'
>(6.3ms)  ROLLBACK
>   Query Trace > (irb):1:in `irb_binding'
>(6.0ms)  BEGIN
>   Query Trace > (irb):1:in `irb_binding'
>   PressRelease Exists (12.7ms)  SELECT  1 AS one FROM `press_releases` WHERE 
> `press_releases`.`id` != 5 AND `press_releases`.`slug` = 
> 'al-basile-creates-new-roots-music-masterpiece-with-b-s-expression-due-september-18-on-sweetspot-records-latest-release-is-most-fully-realized-album-yet'
>  LIMIT 1
>   Query Trace > (irb):1:in `irb_binding'
>(8.1ms)  ROLLBACK
>   Query Trace > (irb):1:in `irb_binding'
>(6.0ms)  BEGIN
>   Query Trace > (irb):1:in `irb_binding'
>   PressRelease Exists (8.9ms)  SELECT  1 AS one FROM `press_releases` WHERE 
> `press_releases`.`id` != 6 AND `press_releases`.`slug` = 
> 'new-cd-from-british-blues-godfather-john-mayall-find-a-way-to-care-set-for-release-september-4th-on-forty-below-records-vinyl-lp-to-follow-in-fall'
>  LIMIT 1
>   Query Trace > (irb):1:in `irb_binding'
>(6.8ms)  ROLLBACK
>   Query Trace > (irb):1:in `irb_binding'
> 
> 

Okay, since you're not in the development console, and aren't handling a PUT or 
PATCH, you don't have parameters to look at here. So this is less useful than I 
had hoped. Please answer these questions, preferably inline, so I don't have to 
play hunt-and-peck to figure this out.

1. When you added FriendlyId to your app, did you use the built-in generator to 
add the friendly_id_slugs table to your app?

2. After you added gem 'friendly_id' to your Gemfile, and ran bundle install, 
did you at any point after that do anything that caused the friendly_id gem to 
upgrade to a newer version? Hint: look thro

Re: [Rails] url slugs with special characters

2019-01-26 Thread Walter Lee Davis


> On Jan 26, 2019, at 11:49 PM, fugee ohu  wrote:
> 
> 
> 
> On Saturday, January 26, 2019 at 6:58:17 PM UTC-5, Walter Lee Davis wrote:
> 
> > On Jan 26, 2019, at 5:27 PM, fugee ohu  wrote: 
> > 
> > TypeError: no implicit conversion of Symbol into Integer 
> > from app/models/press_release.rb:17:in `truncated_headline' 
> > 
> > 
> > class PressRelease < ApplicationRecord 
> > 
> >   extend FriendlyId 
> >   friendly_id :truncated_headline, use: :slugged 
> > 
> >   
> >   def truncated_headline 
> >   # cut off at 200 characters, without an ellipsis 
> > headline.truncate(255, '') 
> >   end 
> > 
> 
> Aha. truncate takes named arguments past the first one. The correct signature 
> is 
> 
> headline.truncate(255, omission: '') 
> 
> This should work. 
> 
> Walter
> 
> Still rolling back 
> 
> 

Show me an example from your development console. Copy and paste. Make sure 
that you include the part where we can see the parameters being passed into 
your controller. I suspect that you are trying to pass a type = 'admin' 
parameter somewhere, that's what the error looked like earlier. Type columns in 
polymorphic relationships must be passed a valid constant name, which will 
begin with an upper-case letter. If there is a model in that relationship named 
admin, you would pass Admin rather than admin. 

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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/3835E9CC-92C0-4C59-B73E-54BAF36B399C%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] url slugs with special characters

2019-01-26 Thread Walter Lee Davis


> On Jan 26, 2019, at 5:27 PM, fugee ohu  wrote:
> 
> TypeError: no implicit conversion of Symbol into Integer
> from app/models/press_release.rb:17:in `truncated_headline'
> 
> 
> class PressRelease < ApplicationRecord
> 
>   extend FriendlyId
>   friendly_id :truncated_headline, use: :slugged
> 
>  
>   def truncated_headline 
>   # cut off at 200 characters, without an ellipsis 
>   headline.truncate(255, '') 
>   end 
> 

Aha. truncate takes named arguments past the first one. The correct signature 
is 

headline.truncate(255, omission: '')

This should work.

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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/8D6F2BBA-54B6-45EA-998E-ABD1AF7D3D6B%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] AWS and hosting a Website

2019-01-26 Thread Walter Lee Davis


> On Jan 26, 2019, at 2:28 PM, Hassan Schroeder  
> wrote:
> 
> On Sat, Jan 26, 2019 at 11:20 AM David Merrick  wrote:
> 
>> I want a AWS Service that I can set up to run a Website with a Domain Name 
>> attached and keep it while I'm not logged into Amazon?
> 
> Unless you want to plunge into exploring container-land, what's wrong
> with an EC2 instance and Route53 for DNS?
> 
> -- 
> Hassan Schroeder  hassan.schroe...@gmail.com
> twitter: @hassan
> Consulting Availability : Silicon Valley or remote
> 

And once you have an EC2 instance, set up a separate static IP address in the 
EC2 control panel, which you can switch around to different instances, or 
assign to an Elastic Load Balancer if you want to stand up multiple instances 
of the same app on separate VPSs.

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+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yAzdY4vUSMP%3DVYU18Qubae2yLSBRAG43nTsqgP_oQeLHQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/1F25E40F-5CDA-4F6E-AC26-39DFDE3A6FEA%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] url slugs with special characters

2019-01-26 Thread Walter Lee Davis


> On Jan 26, 2019, at 1:57 PM, fugee ohu  wrote:
> 
> 
> 
> On Saturday, January 26, 2019 at 12:56:04 PM UTC-5, Walter Lee Davis wrote:
> 
> > On Jan 26, 2019, at 5:27 AM, fugee ohu  wrote: 
> > 
> > 
> > 
> > On Friday, January 25, 2019 at 9:06:22 AM UTC-5, Walter Lee Davis wrote: 
> > 
> > > On Jan 25, 2019, at 6:00 AM, fugee ohu  wrote: 
> > > 
> > > I wanna convert my news stories to use slug urls based on the :headline 
> > > column instead of id's but some of the rows contain special characters 
> > > like double quotes, exclamation points, do I need to gsub those out 
> > 
> > An interesting theory, but FriendlyId already does this, quite elaborately. 
> > The logic that does the "dumbification" is delegated to ActiveSupport's 
> > parameterize method, which takes everything not-ASCII and transliterates it 
> > into ASCII, and replaces any run of whitespace with a single dash, and 
> > removes punctuation. Next, the slug is checked for duplicates with any 
> > existing record, and a UUID is appended if so. It's really quite well done 
> > and very settled code. I have been using FriendlyId for 8 years or more 
> > without encountering any error that wasn't my own mistake. 
> > 
> > In another of your many threads, you mention that you are trying to create 
> > a slug out of the article's text, rather than the headline (as the 
> > documentation encourages). You may want to try starting from a truncated 
> > copy of the article text (or even following the directions) before you 
> > assume that FriendlyId is at fault here. I doubt that your article text 
> > will fit into the size constraints of a URL segment, particularly if you 
> > worry about IE users seeing the thing at all*' 
> > 
> > Walter 
> > 
> > *The entire URL, including prefix, host, port, and path, must be no more 
> > than 1,024 characters ASCII in order to be visited by IE. 
> > 
> > 
> > So I have to change the length of the varchar field and the length of the 
> > index as well? 
> 
> I don't know what your schema looks like right now. Here's how I have always 
> used FriendlyID: 
> 
> 1. I have a `title` column, normal string, 255 characters limit. The client 
> or user can enter whatever she wants up to that limit. 
> 2. I use the FriendlyID migration generator to create the slug column on my 
> model. 
> 3. I configure FriendlyID according to the  instructions (extend, then 
> friendly_id :title, use: :slugged in the model). 
> 4. Profit. 
> 
> There's really nothing else needed except changing find to friendly.find in 
> the controller. 
> 
> I don't give the client/user the ability to create a too-long slug, by 
> starting from a source text that is short enough. 
> 
> If you wanted to start from the article text (say, a true text field of 
> thousands of characters), I would start by trimming that text down to the 
> first couple hundred characters. And then, because slugs must be unique, I 
> would imagine you would have quite a few natural collisions, and might end up 
> with a fair amount of disambiguated slugs that end in UUID-shaped garbage 
> strings. 
> 
> I believe that FriendlyId has the ability to call methods (rather than being 
> bound to just the actual database columns) when calculating the slug, so you 
> could start from `article_body` (a text column, tens of thousands of 
> characters or a clob) and then limit that with truncate or another 
> string-splitting method, like this: 
> 
> (in your model) 
> 
> friendly_id :article_preview, use: :slugged 
> 
> def article_preview 
>   # cut off at 200 characters, without an ellipsis 
>   article_text.truncate(200, '') 
> end 
> 
> Does that make sense? 
> 
> 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-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/0d80957a-d522-4f30-9aeb-a355ea132b0b%40googlegroups.com.
> >  
> > For more options, visit https://groups.google.com/d/optout. 
> 
> 
> Yes I forgot that my :headline column is actually text so this would be 
> necessary Also I don't see reason to use friendly_id for anything but the  
> show action, why try to find records by slug for edits, updates and deletes?
> 

No, there's no actual

Re: [Rails] url slugs with special characters

2019-01-26 Thread Walter Lee Davis


> On Jan 26, 2019, at 5:27 AM, fugee ohu  wrote:
> 
> 
> 
> On Friday, January 25, 2019 at 9:06:22 AM UTC-5, Walter Lee Davis wrote:
> 
> > On Jan 25, 2019, at 6:00 AM, fugee ohu  wrote: 
> > 
> > I wanna convert my news stories to use slug urls based on the :headline 
> > column instead of id's but some of the rows contain special characters like 
> > double quotes, exclamation points, do I need to gsub those out 
> 
> An interesting theory, but FriendlyId already does this, quite elaborately. 
> The logic that does the "dumbification" is delegated to ActiveSupport's 
> parameterize method, which takes everything not-ASCII and transliterates it 
> into ASCII, and replaces any run of whitespace with a single dash, and 
> removes punctuation. Next, the slug is checked for duplicates with any 
> existing record, and a UUID is appended if so. It's really quite well done 
> and very settled code. I have been using FriendlyId for 8 years or more 
> without encountering any error that wasn't my own mistake. 
> 
> In another of your many threads, you mention that you are trying to create a 
> slug out of the article's text, rather than the headline (as the 
> documentation encourages). You may want to try starting from a truncated copy 
> of the article text (or even following the directions) before you assume that 
> FriendlyId is at fault here. I doubt that your article text will fit into the 
> size constraints of a URL segment, particularly if you worry about IE users 
> seeing the thing at all*' 
> 
> Walter 
> 
> *The entire URL, including prefix, host, port, and path, must be no more than 
> 1,024 characters ASCII in order to be visited by IE. 
> 
> 
> So I have to change the length of the varchar field and the length of the 
> index as well? 

I don't know what your schema looks like right now. Here's how I have always 
used FriendlyID:

1. I have a `title` column, normal string, 255 characters limit. The client or 
user can enter whatever she wants up to that limit.
2. I use the FriendlyID migration generator to create the slug column on my 
model.
3. I configure FriendlyID according to the  instructions (extend, then 
friendly_id :title, use: :slugged in the model).
4. Profit.

There's really nothing else needed except changing find to friendly.find in the 
controller.

I don't give the client/user the ability to create a too-long slug, by starting 
from a source text that is short enough. 

If you wanted to start from the article text (say, a true text field of 
thousands of characters), I would start by trimming that text down to the first 
couple hundred characters. And then, because slugs must be unique, I would 
imagine you would have quite a few natural collisions, and might end up with a 
fair amount of disambiguated slugs that end in UUID-shaped garbage strings.

I believe that FriendlyId has the ability to call methods (rather than being 
bound to just the actual database columns) when calculating the slug, so you 
could start from `article_body` (a text column, tens of thousands of characters 
or a clob) and then limit that with truncate or another string-splitting 
method, like this:

(in your model)

friendly_id :article_preview, use: :slugged

def article_preview
  # cut off at 200 characters, without an ellipsis
  article_text.truncate(200, '')
end

Does that make sense?

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+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/0d80957a-d522-4f30-9aeb-a355ea132b0b%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CDC664B7-5E11-404B-A1AA-1F0B35E3D1F5%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.


  1   2   3   4   5   6   7   8   9   10   >