Re: [Rails] finding function defenition

2020-03-21 Thread Ariel Juodziukynas
One thing you can do is use a gem like byebug, put a breakpoint above the
code you want to find it's location and use this:

method(:name_of_method).source_location

if you put a breakpoint inside your routes.rb and call:

method(:get).source_location

it returns something like:

./gems/actionpack-6.0.2.2/lib/action_dispatch/routing/mapper.rb, 711

Than you can check the source on github

https://github.com/rails/rails/blob/v6.0.2.2/actionpack/lib/action_dispatch/routing/mapper.rb#L711

It doesn't always work, you can have methods generated on the fly using
define_method for example I'm not sure source_location gives you the right
source there.

El sáb., 21 mar. 2020 a las 17:36, Ilya Makedon (<
engineer.plusp...@gmail.com>) escribió:

> San Ji, thank for your answer.  But how does Ruby runtime know which
> function to call?  There must be a way for human to mimic that...  Right?
>
> On Sat, Mar 21, 2020 at 10:35 AM San Ji  wrote:
>
>> To my knowledge, what you are looking for is not possible for Ruby.
>>
>> What you got in RubyMine is the closest, basically it index all words and
>> apply some language heuristics to scope down choices. This is good enough
>> in most cases.
>>
>> Systematic way to do it is impossible because Ruby supports
>> metaprogramming.
>> Take ActiveRecord as an example, you got attribute-related methods that
>> defines in databases, not even in Ruby code. If you connect to different
>> databases, the method definitions will be different. Nothing can even point
>> that out (represent that) properly, at least not with user interface of an
>> IDE.
>>
>> --
>> You received this message because you are subscribed 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/63fd8953-f3a8-47a9-a931-17dd2eb3cce4%40googlegroups.com
>> .
>>
>
>
> --
> --
> - Ilya Makedon
>
> --
> You received this message because you are subscribed 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/CAOJppg6O0txtYvKgXzEVaeNqM_%3D5Czofe-4vQZZCi-uYHFTaBA%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/CAPS3bcBXi0BiPo%2BkB7nT8QdNP2orFYcg0oM95pQBDYodyUtQpA%40mail.gmail.com.


Re: [Rails] On polymorphic associations with has_many through, is it possible to pull in multiple source types with one query?

2020-03-19 Thread Ariel Juodziukynas
I'm not sure if you can have all that with a single AR query, I think you
need a custom query (I would use a UNION query an I think AR doesn't
support that)

El jue., 19 mar. 2020 a las 13:25, Blake LeBlanc ()
escribió:

> When dealing with polymorphic associations, is it possible to have a
> has_many through query that pulls in ALL available source_types?
>
> My understanding so far is that each source type needs its own query
> method, as I show here in the Image model
>
> **image.rb**
> ```
> has_many :image_tags
> has_many :tags, through: :image_tags, source: :taggable, source_type: 'Tag'
> has_many :people, through: :image_tags, source: :taggable, source_type:
> 'Person'
> has_many :businesses, through: :image_tags, source: :taggable,
> source_type: 'Business'
> ...
> ```
>
> **tag.rb**
> ```
> has_many :image_tags, as: :taggable
> has_many :images, through: :image_tags
> ```
>
> **image_tag.rb**
>
> ```
> belongs_to :image
> belongs_to :taggable, polymorphic: true
>
> def build_taggable(params)
>   self.taggable = taggable_type.constantize.new(params)
> end
> ```
>
> What I'd like to be able to do, however, is create one query method that
> pulls in all associated records regardless of what source_type they might
> belong to.
>
> Just thinking out loud, would that likely involve creating some sort of
> raw SQL join that acts directly on the ImageTags table? Or is there a more
> Railsy/ActiveRecordy way of approaching it?
>
> Thank you in advance for any help or insights!
> -Blake
>
> --
> You received this message because you are subscribed 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/c537e34b-2d49-4e30-a197-2668fb773f99%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/CAPS3bcBnGfBU4xB_yc%3DBdKG8zEpZ-UKKwi2td68qYgkLPP-xhw%40mail.gmail.com.


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

2020-03-14 Thread Ariel Juodziukynas
Sorry, using different db on different environment is not something I'm
recommending, it was just to point out that the transition should be really
easy. I do think it's faster to prototype using sqlite as long as it fits
the needs, but in a more mature projects I would use the same db everywhere
so I can use all the features I need.

I didn't have that many projects with postgres to talk about upgrading
versions and those things, but personally I never had issues with MySQL
either.

About encodings and collations, I guess it depends on the error but if you
have encoding or collation errors I guess the problem is the configuration
of your tables and the input and not the actual db, you may encounter
problems with any db if you try to handle incompatible encodings at the
same time.

I've used PgAdmin, but didn't try others to compare or recommend anything.

One more thing you can do if you don't want to struggle with updates,
version, etc, is to use docker maybe, you just run the image on any system
and you can replicate the actual production environment anywhere.

El sáb., 14 mar. 2020 a las 14:07, Walter Lee Davis ()
escribió:

>
>
> > 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
> >>
> >> --
> >>

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

2020-03-14 Thread Ariel Juodziukynas
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.


Re: [Rails] Rails session

2020-03-12 Thread Ariel Juodziukynas
I guess you have to use a before block to cache the initial value and then
compare that to the final value in the after block

El jue., 12 mar. 2020 a las 4:08, Jaleel Ahmed ()
escribió:

> I was wondering if it is possible to know if the rails session has been
> modified?
>
> I am having a around filter, I make changes to the session object
> I then yield to the action being performed, the action might not might not
> change the session object. In the after block I want to figure out if the
> session has been altered?
>
> Thanks,
> Jaleel
>
> --
> You received this message because you are subscribed 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/7e3904d7-680c-485a-99fd-9c85455c2352%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/CAPS3bcD6GQvLzufr2LYntyEc3ikjUrinoApJ2qno4HgEUhj3xQ%40mail.gmail.com.


Re: [Rails] Froala WYSIWYG Editor on Rails 6

2020-02-20 Thread Ariel Juodziukynas
What have ou tried? There's a gem but I think it's only intended to be used
with Sprockets and not Webpacker, I would start with the readme
https://github.com/froala/wysiwyg-editor using the npm package and
importing froala as a module
https://github.com/froala/wysiwyg-editor#load-froala-editor-as-a-transpiled-es6umd-module

El jue., 20 feb. 2020 a las 11:44, San Ji () escribió:

> Hard to pass this thread without mentioning Action Text; It is the Rails
> way of WYSIWYG editor and shipped with Rails 6.
>
> If you know about it already, NVM.
> As for the question itself, I never heard about Froala until today.
>
> --
> You received this message because you are subscribed 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/f6881350-8dc3-4c6e-88d0-22729f1163d0%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/CAPS3bcDJYbXNs7Z9g%3Dkq0vcxCHwEiaGzahsJNbinqEK2hy-zLA%40mail.gmail.com.


Re: [Rails] Delayed job :: URGENT

2020-02-19 Thread Ariel Juodziukynas
Each worker runs on a process. When you run the "ps" command on linux
you'll see a list of processes running on your system, you'll have as many
delayed job processes as you have configured. Each of those processes run a
delayed job worker.

El mié., 19 feb. 2020 a las 3:21, Shubham Thakur (<
shubha...@sodelsolutions.com>) escribió:

> Hi,
>
> I am bit confused in rails delayed job
>
> 1) what is workers
> 2) what is process?
> 3) both workers and processes are same ???
>
> --
> You received this message because you are subscribed 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/34a0c565-175e-4fa9-bc61-f2f8523c20a4%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/CAPS3bcAoL-ja5bkBRN%2B3hWEzRcMzbP9SLSCCkqo9i635KBQ0vQ%40mail.gmail.com.


Re: [Rails] Why do basic forms not work in Rails 6 without binding events to each form?

2020-02-18 Thread Ariel Juodziukynas
I understand your complain, what I'm saying is that I have some rails 6
projects using form_for remote and form_with and I didn't have to bind to
the ajax events. rails-ujs and jquery_ujs both expect you to render a view
with .js format and both libraries executes your response's javascript.

Are you rendering a js view when you process the unsubscribe action? what
does you action do? what do you respond to the user from your server? you
have to tell rails what to do when you submit the form, how are you telling
rails what to do?

El mar., 18 feb. 2020 a las 14:46, Momeas Interactive ()
escribió:

>
> Yes, I was discussing this in the Slack channel yesterday in the #coding
> room
>
> You're right that Rails no longer installs JQUery by default, but lots of
> things just go ahead and encourage it anyway. (which Is fine and not what
> I'm complaining about)
>
>
> This guide, for example, as I said above, encourages you to use jQUery to
> add Ajax events to your form submit:
>
>
> https://guides.rubyonrails.org/working_with_javascript_in_rails.html#remote-elements
>
> You could of course not use jQuery and do it another way, except that
> rails-ujs, which is really the problem here, expect you not to.
>
> Right at the top of the https://github.com/rails/jquery-ujs/wiki/ajax docs
> it says that the UJS events are emitted through jQuery.
>
> So I realize that UJS is also at play here, and neither UJS nor jQUery are
> my complaints.
>
> My complaint is that this obscure non-intuitive part of Rails is required
> to do something basic-- like submit a form-- and that Rails 6 has too much
> configuration over convention.
>
> These days when I install Rails 6 all I do is configuration,
> configuration, configuration (and fighting with these obscure parts of
> Rails to configure it some more)
> my code just looks like this:
>
>
> - if @unsubscribe
>   = form_with url: '/unsubscribe' do |f|
> = f.hidden_field :email, value: @unsubscribe.email
> = f.hidden_field :nonce, value: @unsubscribe.nonce
>
> You are confirming that you want to unsubscribe:
> %br
> %br
> = f.text_field :email, disabled: true, value: @unsubscribe.email
> %br
> %br
> = f.submit 'Unsubscribe'
>
>
> When I do this, the form is submitted as Javascript (JS). if I add local:
> true then the form is submitted as HTML.
>
> *This is not a bug, it is a complaint. *
>
> the default behavior (to submit using JS) shouldn't leave my app in a
> non-working buggy state (nothing happens unless you bind an event to the
> Ajax event). that's the complaint.
>
> -Jason
>
>
>
>
>
> On Tuesday, February 18, 2020 at 12:27:26 PM UTC-5, Ariel Juodziukynas
> wrote:
>>
>> And also (sorry for the multiple responses), you are showing jquery code,
>> rails moved out of jquery a long time ago (I think docs are outdated
>> though), something might be wrong with your setup.
>>
>> El mar., 18 feb. 2020 a las 14:25, Ariel Juodziukynas ()
>> escribió:
>>
>>> Can you share some code to reproduce the problem? (a github repo with a
>>> simple rais app would be greate)
>>>
>>> El mar., 18 feb. 2020 a las 14:24, Ariel Juodziukynas (<
>>> arie...@gmail.com>) escribió:
>>>
>>>> I have a few rails 6 projects and remote forms works out of the box
>>>> with no event binding. Can you reproduce that problem with a clean
>>>> rails app? maybe you have some other js messing up rails' ajax handers.
>>>>
>>>> El mar., 18 feb. 2020 a las 14:22, Momeas Interactive (<
>>>> te...@datatravels.com>) escribió:
>>>>
>>>>> Incorrect. You HAVE to bind your Ajax events, or else there is no
>>>>> functionality. (the page does not refresh and gives no user interaction). 
>>>>> I
>>>>> do not think that expecting user interaction is an abnormal expectation in
>>>>> a modern web app.
>>>>>
>>>>>
>>>>>
>>>>> On Sunday, February 16, 2020 at 5:39:20 PM UTC-5, Ariel Juodziukynas
>>>>> wrote:
>>>>>>
>>>>>> It doesn't say you that you HAVE to bind all the ajax events. It
>>>>>> explicitly says that you "probably" want to do that if you "probably" 
>>>>>> want
>>>>>> to do something other than just submitting the form.
>>>>>>
>>>>>> El dom., 16 feb. 2020 a las 17:53, Momeas Interactive (<
>>>>>> te...@datatravels.com>) escribió:
>>>>>>
>>>>>>> i

Re: [Rails] Why do basic forms not work in Rails 6 without binding events to each form?

2020-02-18 Thread Ariel Juodziukynas
And also (sorry for the multiple responses), you are showing jquery code,
rails moved out of jquery a long time ago (I think docs are outdated
though), something might be wrong with your setup.

El mar., 18 feb. 2020 a las 14:25, Ariel Juodziukynas ()
escribió:

> Can you share some code to reproduce the problem? (a github repo with a
> simple rais app would be greate)
>
> El mar., 18 feb. 2020 a las 14:24, Ariel Juodziukynas (<
> arielj...@gmail.com>) escribió:
>
>> I have a few rails 6 projects and remote forms works out of the box with
>> no event binding. Can you reproduce that problem with a clean rails app?
>> maybe you have some other js messing up rails' ajax handers.
>>
>> El mar., 18 feb. 2020 a las 14:22, Momeas Interactive (<
>> t...@datatravels.com>) escribió:
>>
>>> Incorrect. You HAVE to bind your Ajax events, or else there is no
>>> functionality. (the page does not refresh and gives no user interaction). I
>>> do not think that expecting user interaction is an abnormal expectation in
>>> a modern web app.
>>>
>>>
>>>
>>> On Sunday, February 16, 2020 at 5:39:20 PM UTC-5, Ariel Juodziukynas
>>> wrote:
>>>>
>>>> It doesn't say you that you HAVE to bind all the ajax events. It
>>>> explicitly says that you "probably" want to do that if you "probably" want
>>>> to do something other than just submitting the form.
>>>>
>>>> El dom., 16 feb. 2020 a las 17:53, Momeas Interactive (<
>>>> te...@datatravels.com>) escribió:
>>>>
>>>>> it says here in the docs that for turobolinks that you now have to
>>>>> BIND ALL YOUR AJAX EVENTS  (!?!?) if you want your forms to submit
>>>>> correctly.
>>>>>
>>>>>
>>>>> https://guides.rubyonrails.org/working_with_javascript_in_rails.html#remote-elements
>>>>>
>>>>>
>>>>> "You probably don't want to just sit there with a filled out ,
>>>>> though. You probably want to do something upon a successful submission. To
>>>>> do that, bind to the ajax:success event. On failure, use ajax:error. Check
>>>>> it out:"
>>>>>
>>>>> $(document).ready ->
>>>>>   $("#new_article").on("ajax:success", (event) ->
>>>>> [data, status, xhr] = event.detail
>>>>> $("#new_article").append xhr.responseText
>>>>>   ).on "ajax:error", (event) ->
>>>>> $("#new_article").append "ERROR"
>>>>>
>>>>>
>>>>> basically… sitting there with a filled out form is exactly what
>>>>> happens if you just do a generic form_with and post it now in Rails 6 …
>>>>> literally, the user just sits there and nothing happens.
>>>>>
>>>>> are you really supposed to bind all your turbolinks forms throughout
>>>>> your website like this? This seems totally nuts to me, and, kind of, not 
>>>>> at
>>>>> all 'unobtrusive' … (I thought the whole point of 'unobtrusive' was to not
>>>>> have to write a lot of helper/glue/boiler plate code.)
>>>>>
>>>>> it seems totally crazy to me that out-of-the-box Rails 6 installations
>>>>> can't do the most basic web function of submitting a form without the
>>>>> developer having to know about binding events of the Ajax calls. In the 
>>>>> old
>>>>> days didn't this used to 'just work' out of the box?
>>>>>
>>>>> anyone else have any thoughts on this and think Rails is moving in the
>>>>> wrong direction here? The main attraction of Rais is how easy it is to 
>>>>> make
>>>>> so much functionality with little config and effort, and this area seems
>>>>> too basic to me to require this top-heavy approach that requires binding 
>>>>> up
>>>>> Ajax events.
>>>>>
>>>>> I think Rails 7 should move away from having turbolinks turned on by
>>>>> default — it's a good technology if you want to opt-in to it, but it's got
>>>>> so much configuration that it often just gets in the way for new Rails
>>>>> apps. It would be very easy to simply leave off Turbolinks in default 
>>>>> Rails
>>>>> apps and then simply provide instructions for opting-in to it. (Like,
>>>>>

Re: [Rails] Why do basic forms not work in Rails 6 without binding events to each form?

2020-02-18 Thread Ariel Juodziukynas
Can you share some code to reproduce the problem? (a github repo with a
simple rais app would be greate)

El mar., 18 feb. 2020 a las 14:24, Ariel Juodziukynas ()
escribió:

> I have a few rails 6 projects and remote forms works out of the box with
> no event binding. Can you reproduce that problem with a clean rails app?
> maybe you have some other js messing up rails' ajax handers.
>
> El mar., 18 feb. 2020 a las 14:22, Momeas Interactive (<
> t...@datatravels.com>) escribió:
>
>> Incorrect. You HAVE to bind your Ajax events, or else there is no
>> functionality. (the page does not refresh and gives no user interaction). I
>> do not think that expecting user interaction is an abnormal expectation in
>> a modern web app.
>>
>>
>>
>> On Sunday, February 16, 2020 at 5:39:20 PM UTC-5, Ariel Juodziukynas
>> wrote:
>>>
>>> It doesn't say you that you HAVE to bind all the ajax events. It
>>> explicitly says that you "probably" want to do that if you "probably" want
>>> to do something other than just submitting the form.
>>>
>>> El dom., 16 feb. 2020 a las 17:53, Momeas Interactive (<
>>> te...@datatravels.com>) escribió:
>>>
>>>> it says here in the docs that for turobolinks that you now have to BIND
>>>> ALL YOUR AJAX EVENTS  (!?!?) if you want your forms to submit correctly.
>>>>
>>>>
>>>> https://guides.rubyonrails.org/working_with_javascript_in_rails.html#remote-elements
>>>>
>>>>
>>>> "You probably don't want to just sit there with a filled out ,
>>>> though. You probably want to do something upon a successful submission. To
>>>> do that, bind to the ajax:success event. On failure, use ajax:error. Check
>>>> it out:"
>>>>
>>>> $(document).ready ->
>>>>   $("#new_article").on("ajax:success", (event) ->
>>>> [data, status, xhr] = event.detail
>>>> $("#new_article").append xhr.responseText
>>>>   ).on "ajax:error", (event) ->
>>>> $("#new_article").append "ERROR"
>>>>
>>>>
>>>> basically… sitting there with a filled out form is exactly what happens
>>>> if you just do a generic form_with and post it now in Rails 6 … literally,
>>>> the user just sits there and nothing happens.
>>>>
>>>> are you really supposed to bind all your turbolinks forms throughout
>>>> your website like this? This seems totally nuts to me, and, kind of, not at
>>>> all 'unobtrusive' … (I thought the whole point of 'unobtrusive' was to not
>>>> have to write a lot of helper/glue/boiler plate code.)
>>>>
>>>> it seems totally crazy to me that out-of-the-box Rails 6 installations
>>>> can't do the most basic web function of submitting a form without the
>>>> developer having to know about binding events of the Ajax calls. In the old
>>>> days didn't this used to 'just work' out of the box?
>>>>
>>>> anyone else have any thoughts on this and think Rails is moving in the
>>>> wrong direction here? The main attraction of Rais is how easy it is to make
>>>> so much functionality with little config and effort, and this area seems
>>>> too basic to me to require this top-heavy approach that requires binding up
>>>> Ajax events.
>>>>
>>>> I think Rails 7 should move away from having turbolinks turned on by
>>>> default — it's a good technology if you want to opt-in to it, but it's got
>>>> so much configuration that it often just gets in the way for new Rails
>>>> apps. It would be very easy to simply leave off Turbolinks in default Rails
>>>> apps and then simply provide instructions for opting-in to it. (Like,
>>>> active record session store and other things that used to be default and
>>>> then were extracted out into separate opt-in gems.)
>>>>
>>>>
>>>> Thoughts?
>>>>
>>>> Jason
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> You received this message because you are subscribed 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

Re: [Rails] Why do basic forms not work in Rails 6 without binding events to each form?

2020-02-18 Thread Ariel Juodziukynas
I have a few rails 6 projects and remote forms works out of the box with no
event binding. Can you reproduce that problem with a clean rails app? maybe
you have some other js messing up rails' ajax handers.

El mar., 18 feb. 2020 a las 14:22, Momeas Interactive ()
escribió:

> Incorrect. You HAVE to bind your Ajax events, or else there is no
> functionality. (the page does not refresh and gives no user interaction). I
> do not think that expecting user interaction is an abnormal expectation in
> a modern web app.
>
>
>
> On Sunday, February 16, 2020 at 5:39:20 PM UTC-5, Ariel Juodziukynas wrote:
>>
>> It doesn't say you that you HAVE to bind all the ajax events. It
>> explicitly says that you "probably" want to do that if you "probably" want
>> to do something other than just submitting the form.
>>
>> El dom., 16 feb. 2020 a las 17:53, Momeas Interactive (<
>> te...@datatravels.com>) escribió:
>>
>>> it says here in the docs that for turobolinks that you now have to BIND
>>> ALL YOUR AJAX EVENTS  (!?!?) if you want your forms to submit correctly.
>>>
>>>
>>> https://guides.rubyonrails.org/working_with_javascript_in_rails.html#remote-elements
>>>
>>>
>>> "You probably don't want to just sit there with a filled out ,
>>> though. You probably want to do something upon a successful submission. To
>>> do that, bind to the ajax:success event. On failure, use ajax:error. Check
>>> it out:"
>>>
>>> $(document).ready ->
>>>   $("#new_article").on("ajax:success", (event) ->
>>> [data, status, xhr] = event.detail
>>> $("#new_article").append xhr.responseText
>>>   ).on "ajax:error", (event) ->
>>> $("#new_article").append "ERROR"
>>>
>>>
>>> basically… sitting there with a filled out form is exactly what happens
>>> if you just do a generic form_with and post it now in Rails 6 … literally,
>>> the user just sits there and nothing happens.
>>>
>>> are you really supposed to bind all your turbolinks forms throughout
>>> your website like this? This seems totally nuts to me, and, kind of, not at
>>> all 'unobtrusive' … (I thought the whole point of 'unobtrusive' was to not
>>> have to write a lot of helper/glue/boiler plate code.)
>>>
>>> it seems totally crazy to me that out-of-the-box Rails 6 installations
>>> can't do the most basic web function of submitting a form without the
>>> developer having to know about binding events of the Ajax calls. In the old
>>> days didn't this used to 'just work' out of the box?
>>>
>>> anyone else have any thoughts on this and think Rails is moving in the
>>> wrong direction here? The main attraction of Rais is how easy it is to make
>>> so much functionality with little config and effort, and this area seems
>>> too basic to me to require this top-heavy approach that requires binding up
>>> Ajax events.
>>>
>>> I think Rails 7 should move away from having turbolinks turned on by
>>> default — it's a good technology if you want to opt-in to it, but it's got
>>> so much configuration that it often just gets in the way for new Rails
>>> apps. It would be very easy to simply leave off Turbolinks in default Rails
>>> apps and then simply provide instructions for opting-in to it. (Like,
>>> active record session store and other things that used to be default and
>>> then were extracted out into separate opt-in gems.)
>>>
>>>
>>> Thoughts?
>>>
>>> Jason
>>>
>>>
>>>
>>>
>>>
>>> --
>>> You received this message because you are subscribed 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/511637f0-dec3-4bd1-9648-a823c140669b%40googlegroups.com
>>> <https://groups.google.com/d/msgid/rubyonrails-talk/511637f0-dec3-4bd1-9648-a823c140669b%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>> --
> You received this message because you are subscribed 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/39ae14f7-72e1-48c3-9d44-371a4e9a799f%40googlegroups.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/39ae14f7-72e1-48c3-9d44-371a4e9a799f%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
You received this message because you are subscribed 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/CAPS3bcD3pz32uZN%3DPMOBRkM%3DdRr%2BGqCxS5o5zV9ChUQLdzpDyA%40mail.gmail.com.


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

2020-02-17 Thread Ariel Juodziukynas
accepts_nested_attributes_for explicitly checks for associations to exist
https://github.com/rails/rails/blob/f33d52c95217212cbacc8d5e44b5a8e3cdc6f5b3/activerecord/lib/active_record/nested_attributes.rb#L340

fields_for does not require accepts_nested_attributes_for to be defined,
but it won't behave the same without that, you can inspect the generated
html on both cases

El lun., 17 feb. 2020 a las 6:19, Nicholas Schwaderer (<
nicholas.schwade...@gmail.com>) escribió:

> Hello again Fugee,
>
> Fields in forms in Rails do not necessarily have to correspond with model
> attributes.
>
> Generally, you might find the Rails edge guide on forms very helpful- as
> well as the `form_with` API docs which are a bit more specific for some of
> these questions.
>
> https://guides.rubyonrails.org/form_helpers.html
> https://apidock.com/rails/ActionView/Helpers/FormHelper/form_with
>
> Nick Schwaderer
>
> On Mon, 17 Feb 2020 at 07:45, fugee ohu  wrote:
>
>>
>>
>> On Monday, February 17, 2020 at 12:38:03 AM UTC-5, Walter Lee Davis wrote:
>>>
>>> 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 rubyonra...@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.
>>>
>>>
>>
>> In my app users have many artists, artists have many tourdates, artists
>> have many venues, users have many venues through artists, tour_dates when
>> added have to provide a venue so they can select from clubs or festivals
>> that are included in the app, and they can also create a user defined
>> venue, or select from previous user defined venues I had this working
>> before I started concerning myself with associations by prepending all the
>> venue fields with venue so state and city become venue_state and venue_city
>> and I add an attribute_accessor to the tour_dates model for each venue
>> field I feel like that still the way to do it, as long as the user defined
>> venues belong to the artist and user so if the user ever deletes the artist
>> the venue will be deleted also
>>
>> --
>> You received this message because you are subscribed 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/f2ba1d66-8420-41e9-b228-2456080f0ffb%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/CAGN3KYykHS73kLZ1G4XuQqJrRwzjrJ1wPa2vmtT%2Bib8z-ffMyg%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/CAPS3bcCtF2x6DD6TGsixdK3sU6uW67v0mNFEZen85CZeMeO9DA%40mail.gmail.com.


Re: [Rails] Why do basic forms not work in Rails 6 without binding events to each form?

2020-02-16 Thread Ariel Juodziukynas
It doesn't say you that you HAVE to bind all the ajax events. It explicitly
says that you "probably" want to do that if you "probably" want to do
something other than just submitting the form.

El dom., 16 feb. 2020 a las 17:53, Momeas Interactive ()
escribió:

> it says here in the docs that for turobolinks that you now have to BIND
> ALL YOUR AJAX EVENTS  (!?!?) if you want your forms to submit correctly.
>
>
> https://guides.rubyonrails.org/working_with_javascript_in_rails.html#remote-elements
>
>
> "You probably don't want to just sit there with a filled out ,
> though. You probably want to do something upon a successful submission. To
> do that, bind to the ajax:success event. On failure, use ajax:error. Check
> it out:"
>
> $(document).ready ->
>   $("#new_article").on("ajax:success", (event) ->
> [data, status, xhr] = event.detail
> $("#new_article").append xhr.responseText
>   ).on "ajax:error", (event) ->
> $("#new_article").append "ERROR"
>
>
> basically… sitting there with a filled out form is exactly what happens if
> you just do a generic form_with and post it now in Rails 6 … literally, the
> user just sits there and nothing happens.
>
> are you really supposed to bind all your turbolinks forms throughout your
> website like this? This seems totally nuts to me, and, kind of, not at all
> 'unobtrusive' … (I thought the whole point of 'unobtrusive' was to not have
> to write a lot of helper/glue/boiler plate code.)
>
> it seems totally crazy to me that out-of-the-box Rails 6 installations
> can't do the most basic web function of submitting a form without the
> developer having to know about binding events of the Ajax calls. In the old
> days didn't this used to 'just work' out of the box?
>
> anyone else have any thoughts on this and think Rails is moving in the
> wrong direction here? The main attraction of Rais is how easy it is to make
> so much functionality with little config and effort, and this area seems
> too basic to me to require this top-heavy approach that requires binding up
> Ajax events.
>
> I think Rails 7 should move away from having turbolinks turned on by
> default — it's a good technology if you want to opt-in to it, but it's got
> so much configuration that it often just gets in the way for new Rails
> apps. It would be very easy to simply leave off Turbolinks in default Rails
> apps and then simply provide instructions for opting-in to it. (Like,
> active record session store and other things that used to be default and
> then were extracted out into separate opt-in gems.)
>
>
> Thoughts?
>
> Jason
>
>
>
>
>
> --
> You received this message because you are subscribed 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/511637f0-dec3-4bd1-9648-a823c140669b%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/CAPS3bcA%2BWbyWwg%2BpWgerkaLA5QmxofgfXUN-Nv1krTyYuoWjjg%40mail.gmail.com.


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

2020-01-29 Thread Ariel Juodziukynas
The client part requires javascript, the backend part requires no
javascript, I strongly recommend you read this
https://guides.rubyonrails.org/action_cable_overview.html

Sometimes it looks like you just ask questions without reading about the
subject you try to use. The official guide shows you what file goes where.

El mié., 29 ene. 2020 a las 13:08, fugee ohu ()
escribió:

>
>
> On Wednesday, January 29, 2020 at 8:18:28 AM UTC-5, Walter Lee Davis wrote:
>>
>>
>> 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 rubyonra...@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.
>>
>>
>
> Thanks I'm trying to write an action cable chat app Eventually I want it
> to include video but for now I've got text working but I don't have images
> working yet Do all action cable chat solutions rely on javascript (?)
> because I notice there's an app/channels folder and an
> app/javascript/channels folder Does that mean I don't need to be 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/62555a89-a69e-485b-8117-f17394a5b676%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/CAPS3bcA1qCtFT1JEUaFqmEs-UoMnRj4VAkoGoiPORAwxungSGQ%40mail.gmail.com.


Re: [Rails] activestorage user.avatar.attached? in javascript

2020-01-28 Thread Ariel Juodziukynas
In your case, you CAN'T call "user.avatar.attached?" inside
app/javascript/channels/room_channel.js.erb because it's a request
dependant object.

El mar., 28 ene. 2020 a las 12:24, Ariel Juodziukynas ()
escribió:

> Although you can use .js.erb extension for any .js file you have to
> understand WHEN that erb gets executed to understand what you can do with
> it.
>
> Assets with .erb extension are compiled to JS code during the assets
> precompilation process, you can't put request dependant code (current_user,
> instance variables, request controller/action, etc) inside an .js.erb asset
> file because it's an isolated process (assets are compiled into one final
> static .js bundle).
>
> You can put request dependant code on .js.erb VIEWS because views are
> executed when they are needed for each request.
>
> Not all js files are used the same way, you can use .erb extension to have
> ruby code but have to take into account the context to understand what
> variables you have access to.
>
> El mar., 28 ene. 2020 a las 11:17, fugee ohu ()
> escribió:
>
>>
>>
>> On Monday, January 27, 2020 at 8:28:48 AM UTC-5, Ariel Juodziukynas wrote:
>>>
>>> You can't, you need the .erb extension to execute ruby code.
>>>
>>> El lun., 27 ene. 2020 a las 0:29, fugee ohu ()
>>> escribió:
>>>
>>>> How would I run this same test in javascript without renaming my
>>>> room_channel.js to room_channel.js.erb ?
>>>>
>>>> --
>>>> You received this message because you are subscribed 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/bdf21e73-81a0-4485-957e-82afa0e2d6a9%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/rubyonrails-talk/bdf21e73-81a0-4485-957e-82afa0e2d6a9%40googlegroups.com?utm_medium=email_source=footer>
>>>> .
>>>>
>>>
>> I can change any .js file to .js.erb ? In this case it's
>> app/javascript/channels/room_channel.js Passing data between javascript and
>> rails is an important topic so I wanna learn as best I can without
>> "cheating" but I'm attracted to the js.erb method too, I wanna mix it up
>> something use js.erb sometimes use just .js so I don't end up ignorant
>>
>> --
>> You received this message because you are subscribed 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/3866a144-220f-4e6a-ad06-090226af6ef9%40googlegroups.com
>> <https://groups.google.com/d/msgid/rubyonrails-talk/3866a144-220f-4e6a-ad06-090226af6ef9%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed 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/CAPS3bcAct%3Do%2BwsthvgLRLb2rx5wONGx4Zznh1bDqMYb7%3D%3DYYMQ%40mail.gmail.com.


Re: [Rails] activestorage user.avatar.attached? in javascript

2020-01-28 Thread Ariel Juodziukynas
Although you can use .js.erb extension for any .js file you have to
understand WHEN that erb gets executed to understand what you can do with
it.

Assets with .erb extension are compiled to JS code during the assets
precompilation process, you can't put request dependant code (current_user,
instance variables, request controller/action, etc) inside an .js.erb asset
file because it's an isolated process (assets are compiled into one final
static .js bundle).

You can put request dependant code on .js.erb VIEWS because views are
executed when they are needed for each request.

Not all js files are used the same way, you can use .erb extension to have
ruby code but have to take into account the context to understand what
variables you have access to.

El mar., 28 ene. 2020 a las 11:17, fugee ohu ()
escribió:

>
>
> On Monday, January 27, 2020 at 8:28:48 AM UTC-5, Ariel Juodziukynas wrote:
>>
>> You can't, you need the .erb extension to execute ruby code.
>>
>> El lun., 27 ene. 2020 a las 0:29, fugee ohu ()
>> escribió:
>>
>>> How would I run this same test in javascript without renaming my
>>> room_channel.js to room_channel.js.erb ?
>>>
>>> --
>>> You received this message because you are subscribed 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/bdf21e73-81a0-4485-957e-82afa0e2d6a9%40googlegroups.com
>>> <https://groups.google.com/d/msgid/rubyonrails-talk/bdf21e73-81a0-4485-957e-82afa0e2d6a9%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>>
> I can change any .js file to .js.erb ? In this case it's
> app/javascript/channels/room_channel.js Passing data between javascript and
> rails is an important topic so I wanna learn as best I can without
> "cheating" but I'm attracted to the js.erb method too, I wanna mix it up
> something use js.erb sometimes use just .js so I don't end up ignorant
>
> --
> You received this message because you are subscribed 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/3866a144-220f-4e6a-ad06-090226af6ef9%40googlegroups.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/3866a144-220f-4e6a-ad06-090226af6ef9%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
You received this message because you are subscribed 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/CAPS3bcAKuKSx6WOsJibuiFqe8MmJvTh4N%2B%3D6WUpmFJ3u20CMDA%40mail.gmail.com.


Re: [Rails] activestorage user.avatar.attached? in javascript

2020-01-27 Thread Ariel Juodziukynas
You can't, you need the .erb extension to execute ruby code.

El lun., 27 ene. 2020 a las 0:29, fugee ohu () escribió:

> How would I run this same test in javascript without renaming my
> room_channel.js to room_channel.js.erb ?
>
> --
> You received this message because you are subscribed 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/bdf21e73-81a0-4485-957e-82afa0e2d6a9%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/CAPS3bcA4umMPFHLoXCdEZHa0SegVHt3hXGKYt5HfK4LUiiBzAA%40mail.gmail.com.


Re: [Rails] //= require stylesheet with webpacker

2020-01-18 Thread Ariel Juodziukynas
"//= require ..." is Sprocket's syntax (most known as rails' assets
pipeline), not webpacker's. If you really want to handle CSS assets with
webpacker you should start by reading this
https://github.com/rails/webpacker/blob/master/docs/css.md

El sáb., 18 ene. 2020 a las 4:00, fugee ohu () escribió:

> I have my stylesheet in app/javascript/stylesheets and need to include
> actiontext.scss in application.scss where both files are located in
> app/javascript/stylesheets but using
> //= require actiontext has no effect, styling is still not being applied
>
> --
> You received this message because you are subscribed 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/58c1a214-6a7c-4b16-8e02-60a17cbb15d9%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/CAPS3bcB%2BnhTt-gFNAVHCJYZpGTeDFFATDZr820%2Bf5xqaU-wzsQ%40mail.gmail.com.


Re: [Rails] ActiveRecord find ignores extra characters after numeric id. ?

2020-01-16 Thread Ariel Juodziukynas
I guess you are calling ensure_canonical_url before_action BEFORE
set_blog_post before_action, so it's not already set.

I guess you have something like:

before_action :ensure_canonical_url, only: :show
before_action :set_blog_post, only: :show

swap both lines if so.

El jue., 16 ene. 2020 a las 8:36, fugee ohu () escribió:

>
>
> On Wednesday, January 15, 2020 at 8:41:00 PM UTC-5, Ariel Juodziukynas
> wrote:
>>
>> I insist, show your code, show the complete error stacktrace, show the
>> log. I can imagine what you are trying to do and from the (little) code you
>> show it should work so something else is messing things up but you are
>> showing barely any relevant code.
>>
>> El mié., 15 ene. 2020 a las 22:37, fugee ohu ()
>> escribió:
>>
>>>
>>>
>>> On Wednesday, January 15, 2020 at 8:26:45 PM UTC-5, Ariel Juodziukynas
>>> wrote:
>>>>
>>>> find method doesn't care about the to_param method, it just takes the
>>>> parameter you use, I guess it calls "to_i" and uses that integer to query
>>>> the id column
>>>>
>>>> Why don't you show your code, the stacktrace, the logs or anything? I
>>>> suggest you read something like stackoverflow's guidelines on how to ask,
>>>> you posts are usually really hard to understand and a lot of information is
>>>> missing
>>>>
>>>> El mié., 15 ene. 2020 a las 18:01, fugee ohu ()
>>>> escribió:
>>>>
>>>>>
>>>>>
>>>>> On Wednesday, January 15, 2020 at 3:07:00 PM UTC-5, Ariel Juodziukynas
>>>>> wrote:
>>>>>>
>>>>>> From the docs:
>>>>>> https://apidock.com/rails/v6.0.0/ActiveRecord/FinderMethods/find
>>>>>>
>>>>>> Person <https://apidock.com/rails/Person>.find 
>>>>>> <https://apidock.com/rails/ActiveRecord/FinderMethods/find>("31-sarah") 
>>>>>> # returns the object for ID = 31
>>>>>>
>>>>>> In your case, if you are using find, it should search for record with
>>>>>> id = 18
>>>>>>
>>>>>> El mié., 15 ene. 2020 a las 16:18, fugee ohu ()
>>>>>> escribió:
>>>>>>
>>>>>>> Doesn't work for me in rails 6
>>>>>>>
>>>>>>>   Parameters: {"id"=>"18-test-title"}
>>>>>>>  ActionController::ActionControllerError (Cannot redirect to nil!):
>>>>>>>
>>>>>>> Ne
>>>>>>>
>>>>>>> --
>>>>>>> You received this message because you are subscribed 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/64e66550-c393-43cd-8156-29c43139899a%40googlegroups.com
>>>>>>> <https://groups.google.com/d/msgid/rubyonrails-talk/64e66550-c393-43cd-8156-29c43139899a%40googlegroups.com?utm_medium=email_source=footer>
>>>>>>> .
>>>>>>>
>>>>>>
>>>>> I've over-riding ActiveRecord to_param in my model
>>>>>
>>>>>   def to_param
>>>>>"#{id}-#{title.parameterize}"
>>>>>   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/1ba590e7-4c1c-4fcd-9ed8-0f2ed65b0350%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/rubyonrails-talk/1ba590e7-4c1c-4fcd-9ed8-0f2ed65b0350%40googlegroups.com?utm_medium=email_source=footer>
>>>>> .
>>>>>
>>>>
>>> I was trying to implement this guide:
>>>
>>> https://medium.com/badass-engineer/seo-friendly-urls-with-rails-49cfcd2fb190
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>&

Re: [Rails] ActiveRecord find ignores extra characters after numeric id. ?

2020-01-15 Thread Ariel Juodziukynas
I insist, show your code, show the complete error stacktrace, show the log.
I can imagine what you are trying to do and from the (little) code you show
it should work so something else is messing things up but you are showing
barely any relevant code.

El mié., 15 ene. 2020 a las 22:37, fugee ohu ()
escribió:

>
>
> On Wednesday, January 15, 2020 at 8:26:45 PM UTC-5, Ariel Juodziukynas
> wrote:
>>
>> find method doesn't care about the to_param method, it just takes the
>> parameter you use, I guess it calls "to_i" and uses that integer to query
>> the id column
>>
>> Why don't you show your code, the stacktrace, the logs or anything? I
>> suggest you read something like stackoverflow's guidelines on how to ask,
>> you posts are usually really hard to understand and a lot of information is
>> missing
>>
>> El mié., 15 ene. 2020 a las 18:01, fugee ohu ()
>> escribió:
>>
>>>
>>>
>>> On Wednesday, January 15, 2020 at 3:07:00 PM UTC-5, Ariel Juodziukynas
>>> wrote:
>>>>
>>>> From the docs:
>>>> https://apidock.com/rails/v6.0.0/ActiveRecord/FinderMethods/find
>>>>
>>>> Person <https://apidock.com/rails/Person>.find 
>>>> <https://apidock.com/rails/ActiveRecord/FinderMethods/find>("31-sarah") # 
>>>> returns the object for ID = 31
>>>>
>>>> In your case, if you are using find, it should search for record with
>>>> id = 18
>>>>
>>>> El mié., 15 ene. 2020 a las 16:18, fugee ohu ()
>>>> escribió:
>>>>
>>>>> Doesn't work for me in rails 6
>>>>>
>>>>>   Parameters: {"id"=>"18-test-title"}
>>>>>  ActionController::ActionControllerError (Cannot redirect to nil!):
>>>>>
>>>>> Ne
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed 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/64e66550-c393-43cd-8156-29c43139899a%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/rubyonrails-talk/64e66550-c393-43cd-8156-29c43139899a%40googlegroups.com?utm_medium=email_source=footer>
>>>>> .
>>>>>
>>>>
>>> I've over-riding ActiveRecord to_param in my model
>>>
>>>   def to_param
>>>"#{id}-#{title.parameterize}"
>>>   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/1ba590e7-4c1c-4fcd-9ed8-0f2ed65b0350%40googlegroups.com
>>> <https://groups.google.com/d/msgid/rubyonrails-talk/1ba590e7-4c1c-4fcd-9ed8-0f2ed65b0350%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>>
> I was trying to implement this guide:
>
> https://medium.com/badass-engineer/seo-friendly-urls-with-rails-49cfcd2fb190
>
> --
> You received this message because you are subscribed 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/1aa0ed3a-a906-4965-8ff1-c8fde1e909da%40googlegroups.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/1aa0ed3a-a906-4965-8ff1-c8fde1e909da%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
You received this message because you are subscribed 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/CAPS3bcAhMWv_1GduYuKyRe5D%3DexpX_ata7B-kL0fnTwFRc86Tg%40mail.gmail.com.


Re: [Rails] ActiveRecord find ignores extra characters after numeric id. ?

2020-01-15 Thread Ariel Juodziukynas
find method doesn't care about the to_param method, it just takes the
parameter you use, I guess it calls "to_i" and uses that integer to query
the id column

Why don't you show your code, the stacktrace, the logs or anything? I
suggest you read something like stackoverflow's guidelines on how to ask,
you posts are usually really hard to understand and a lot of information is
missing

El mié., 15 ene. 2020 a las 18:01, fugee ohu ()
escribió:

>
>
> On Wednesday, January 15, 2020 at 3:07:00 PM UTC-5, Ariel Juodziukynas
> wrote:
>>
>> From the docs:
>> https://apidock.com/rails/v6.0.0/ActiveRecord/FinderMethods/find
>>
>> Person <https://apidock.com/rails/Person>.find 
>> <https://apidock.com/rails/ActiveRecord/FinderMethods/find>("31-sarah") # 
>> returns the object for ID = 31
>>
>> In your case, if you are using find, it should search for record with id
>> = 18
>>
>> El mié., 15 ene. 2020 a las 16:18, fugee ohu ()
>> escribió:
>>
>>> Doesn't work for me in rails 6
>>>
>>>   Parameters: {"id"=>"18-test-title"}
>>>  ActionController::ActionControllerError (Cannot redirect to nil!):
>>>
>>> Ne
>>>
>>> --
>>> You received this message because you are subscribed 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/64e66550-c393-43cd-8156-29c43139899a%40googlegroups.com
>>> <https://groups.google.com/d/msgid/rubyonrails-talk/64e66550-c393-43cd-8156-29c43139899a%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>>
> I've over-riding ActiveRecord to_param in my model
>
>   def to_param
>"#{id}-#{title.parameterize}"
>   end
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/1ba590e7-4c1c-4fcd-9ed8-0f2ed65b0350%40googlegroups.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/1ba590e7-4c1c-4fcd-9ed8-0f2ed65b0350%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
You received this message because you are subscribed 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/CAPS3bcDQU%2BQLcCOftreFJb0UdUFYUYPAFM%3DCm1xCO2qomsQ6Ag%40mail.gmail.com.


Re: [Rails] ActiveRecord find ignores extra characters after numeric id. ?

2020-01-15 Thread Ariel Juodziukynas
>From the docs:
https://apidock.com/rails/v6.0.0/ActiveRecord/FinderMethods/find

Person .find
("31-sarah")
# returns the object for ID = 31

In your case, if you are using find, it should search for record with id =
18

El mié., 15 ene. 2020 a las 16:18, fugee ohu ()
escribió:

> Doesn't work for me in rails 6
>
>   Parameters: {"id"=>"18-test-title"}
>  ActionController::ActionControllerError (Cannot redirect to nil!):
>
> Ne
>
> --
> You received this message because you are subscribed 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/64e66550-c393-43cd-8156-29c43139899a%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/CAPS3bcA8PH7D9tzqAWTWLF0gK8vYUrO4G5xjJa3rgM41rxP-cw%40mail.gmail.com.


Re: [Rails] how to pass data to javascript in div.content_tag

2020-01-05 Thread Ariel Juodziukynas
data attributes (data-something on an html tag) are accessed using the
"dataset" property of javascript's HTMLElement element
https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/dataset
, that "received(data)" sounds like a callback from a promise or ajax call
to me, that's a totally different thing.

Camel case has two variants: first letter can be lower or upper case (camel
case with capital first letter is also known as PascalCase)

I respond via emails, I guess you delete the post on the google groups page
but the email is already sent.

El dom., 5 ene. 2020 a las 20:17, fugee ohu () escribió:

>
>
> On Sunday, January 5, 2020 at 8:41:33 AM UTC-5, Ariel Juodziukynas wrote:
>>
>> No, the first line is ruby and the convention is snakecase so it's ok you
>> use underscores, the second line is html and the attributes syntax is
>> hyphen, when you access that data attribute with javascript it will be
>> dataset.conversationWithId as camelcase. You should write using the
>> convention of the language you are using, then each language takes care of
>> converting it.
>>
>> El dom., 5 ene. 2020 a las 4:35, fugee ohu ()
>> escribió:
>>
>>> <%= content_tag :div, id: "message_holder", data: {conversation_with_id:
>>> @conversation_with.id} do %>
>>>
>>> translates to this html from page source:
>>>
>>> 
>>>
>>> The underscores get translated to hyphens Should I just rename the variable 
>>> to conversation-with-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/8da006ce-97eb-49d2-aa3f-b2226c8f0ef5%40googlegroups.com
>>> <https://groups.google.com/d/msgid/rubyonrails-talk/8da006ce-97eb-49d2-aa3f-b2226c8f0ef5%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>>
> How are you able to reply after I've deleted my original post It's a
> pattern in here, whenever I delete a post I get a repsonse to a post that I
> already deleted It lends the impression that I've been deleting them after
>
> --
> You received this message because you are subscribed 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/cec31578-1a7e-47e3-ba2b-a7edfa50d98e%40googlegroups.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/cec31578-1a7e-47e3-ba2b-a7edfa50d98e%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
You received this message because you are subscribed 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/CAPS3bcAH%3D%2BMLreTA3raZh7Vvhi6SMeE8uQXyCB2J3wT3-menHA%40mail.gmail.com.


Re: [Rails] how to pass data to javascript in div.content_tag

2020-01-05 Thread Ariel Juodziukynas
No, the first line is ruby and the convention is snakecase so it's ok you
use underscores, the second line is html and the attributes syntax is
hyphen, when you access that data attribute with javascript it will be
dataset.conversationWithId as camelcase. You should write using the
convention of the language you are using, then each language takes care of
converting it.

El dom., 5 ene. 2020 a las 4:35, fugee ohu () escribió:

> <%= content_tag :div, id: "message_holder", data: {conversation_with_id: @
> conversation_with.id} do %>
>
> translates to this html from page source:
>
> 
>
> The underscores get translated to hyphens Should I just rename the variable 
> to conversation-with-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 rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/8da006ce-97eb-49d2-aa3f-b2226c8f0ef5%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/CAPS3bcAcAcc69FuYqsjQD%3DZof8BaxzdiysqkZ8fABLXSOTH_Tw%40mail.gmail.com.


Re: [Rails] app/assets/config/manifest.js

2019-12-31 Thread Ariel Juodziukynas
Sprockets 4 added the manifest.js file
https://github.com/rails/sprockets#upgrading-to-sprockets-4x. It's not a
some rails version thing.

El mar., 31 dic. 2019 a las 14:52, fugee ohu ()
escribió:

> Beginning with what rails version is this path expected to exist?
>
> --
> You received this message because you are subscribed 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/134e419e-b25a-4251-8aff-3cee2fb94f24%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/CAPS3bcBqkvZSm7Hdpo%2BcE41G8Y7iy3eW7Qnp0wVdNEq%2BLYt5wA%40mail.gmail.com.


Re: [Rails] Re: [rails] devise-in18n messages not localized

2019-12-28 Thread Ariel Juodziukynas
>From the code you can see it uses internationalization
https://github.com/plataformatec/devise/blob/098345aace53d4ddf88e04f1eb2680e2676e8c28/app/controllers/devise_controller.rb#L182

You can do something like this on an initializer so override the I18n
lookup method to print each key it tries to find, maybe you can
debug what's going on:

# config/initializers/debug_18n.rb

module I18n
module Backend
class Simple
# Monkey-patch-in localization debugging
# Enable with ENV['I18N_DEBUG']=1 on the command line in server startup, or
./config/environments/*.rb file.
#
def lookup(locale, key, scope = [], options = {})
init_translations unless initialized?
keys = I18n.normalize_keys(locale, key, scope, options[:separator])

puts "I18N keys: #{keys}"

keys.inject(translations) do |result, _key|
_key = _key.to_sym
return nil unless result.is_a?(Hash) && result.has_key?(_key)
result = result[_key]
result = resolve(locale, _key, result, options.merge(:scope => nil)) if
result.is_a?(Symbol)

puts "\t\t => " + result.to_s + "\n" if (result.class == String)

result
end
end
end
end
end

I don't rember where I took that code from to give the credit.

Now you can check that's actually trying to translate (from the code it's:
some_resource_name.some_message)


El sáb., 28 dic. 2019 a las 14:30, Cédric Lefebvre ()
escribió:

> Sure, my application.rb contains the following:
>
> config.i18n.available_locales = [:en, :fr]
> config.i18n.default_locale = :en
> config.i18n.fallbacks = [I18n.default_locale]
>
> The last line of your application.rb comes from heroes Gem, which I do not
> use.
>
> On your website, are you sure the flash messages are localised? And if
> yes, which version of the devise and devise-i18n are you using?
>
> Thanks
>
> Cedric
> On 28. Dec 2019, 14:18 +0100, fugee ohu , wrote:
>
>
>
> On Thursday, December 26, 2019 at 6:17:23 PM UTC-5, Cédric Lefebvre wrote:
>>
>> I have deployed devise & devise-i18n to internationalize devise.
>> Everything works well - including all the i18n - except that flash messages
>> generated by devise do not get translated
>>
>> => messages generated by devise and accessed via
>> resource.errors.full_messages are localized
>> e.g. try to "sign_up" with no information filled in
>>
>>
>> => flashes generated by devise are not localized
>> e.g. try to "sign_in" with no information filled in
>>
>>
>> Any idea why? Any idea on how to fix this?
>>
>
> Have you created settings for i18n in application.rb ?
>
> Here's what application.rb looks like on one of my sites that uses locales:
> Rails.application.config.i18n.available_locales = ["ko", "zh-TW",
> "ja", "en-US"]
> Rails.application.config.i18n.default_locale = "en-US"
> ISO3166.configure do |config|
>config.locales = ['zh-TW', 'en-US', 'ko', 'ja']
>
> --
> You received this message because you are subscribed 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/526f03ab-5181-45e1-9a8d-622e1ec17fb6%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/5b2e492a-a26e-4ee5-86d9-76bcff9fcdeb%40Spark
> 
> .
>

-- 
You received this message because you are subscribed 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/CAPS3bcDCQkyV0biL_ZHH-sGZPk%2Bedx2w2HHx3dwj2sSbT3KB8w%40mail.gmail.com.


Re: [Rails] rails 6 where to put javascript files

2019-12-23 Thread Ariel Juodziukynas
If you have a file inside /packs called application.js that has a line
"import Something from '../some_js'", webpacker will include the code from
"some_js.js" inside the resulting bundle "application.js".

El lun., 23 dic. 2019 a las 12:10, fugee ohu ()
escribió:

>
>
> On Sunday, December 22, 2019 at 6:10:58 PM UTC-5, Ariel Juodziukynas wrote:
>>
>> There's a section specifying where to put js files on the documentation
>> https://github.com/rails/webpacker#paths. You can put the files
>> anywhere, if you put them inside the packs folder webpacker will create
>> bundles using those files, if you put them elsewhere wenpacker will bundle
>> them inside the packs that require them.
>>
>> El dom., 22 dic. 2019 a las 4:48, fugee ohu ()
>> escribió:
>>
>>> Where do I put my custom javascript files now, under javascripts or
>>> under javascripts/packs or should i create a directory like 'custom' under
>>> javascripts and then in javascript/packs/application.js i would have to
>>> import "../custom" and that would import all the javascript files in the
>>> custom directory Can someone please clarify?
>>>
>>> --
>>> You received this message because you are subscribed 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/8295b70b-e09e-4fe3-96ba-cb5017125ace%40googlegroups.com
>>> <https://groups.google.com/d/msgid/rubyonrails-talk/8295b70b-e09e-4fe3-96ba-cb5017125ace%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>>
> wenpacker will bundle them inside the packs that require them
> What does that mean?
>
> --
> You received this message because you are subscribed 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/b479f7ff-e3ce-4337-bd94-12042605bc84%40googlegroups.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/b479f7ff-e3ce-4337-bd94-12042605bc84%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
You received this message because you are subscribed 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/CAPS3bcC-E2JXvA4t51Mhe%3Dgu-wq%2Bqdo1eWxvwh7f02segOWtig%40mail.gmail.com.


Re: [Rails] webpacker images folder

2019-12-22 Thread Ariel Juodziukynas
I've answered another email, everything you are asking seems to be on the
documentation:
https://github.com/rails/webpacker#paths
https://github.com/rails/webpacker/blob/master/docs/assets.md#link-in-your-rails-views
https://github.com/rails/webpacker/blob/master/docs/css.md

El dom., 22 dic. 2019 a las 20:10, fugee ohu ()
escribió:

>
>
> On Sunday, December 22, 2019 at 6:08:08 PM UTC-5, Ariel Juodziukynas wrote:
>>
>> You shouldn't have files inside pack except for the bundles/packs you'll
>> link on your html, images go in javacsripts/images, not in
>> javascripts/packs. Just read the guide
>> https://github.com/rails/webpacker/blob/master/docs/assets.md#link-in-your-rails-views
>>
>> El dom., 22 dic. 2019 a las 15:50, fugee ohu ()
>> escribió:
>>
>>> If I put in application.js require.context('../images', true) everything
>>> works fine regardless of whether I place my images folder under javascripts
>>> or under javascripts/packs If I have my image folder under packs and change
>>> it to require.context('images', true) it breaks
>>>
>>> --
>>> You received this message because you are subscribed 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/acaa913d-e589-4c10-af28-7488d2777f77%40googlegroups.com
>>> <https://groups.google.com/d/msgid/rubyonrails-talk/acaa913d-e589-4c10-af28-7488d2777f77%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>>
> Actually have all my js files inside packs for now Where should I put
> those Note: original question was about images
>
> --
> You received this message because you are subscribed 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/4d2ca96e-903e-4182-baea-d6f0f0b815de%40googlegroups.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/4d2ca96e-903e-4182-baea-d6f0f0b815de%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
You received this message because you are subscribed 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/CAPS3bcDaGUnTUPHK%2BMQW7VvWcV1rxM9D3iewrxBRV%3DLJDtwrwg%40mail.gmail.com.


Re: [Rails] bootstrap nav vs div class: nav

2019-12-22 Thread Ariel Juodziukynas
The "nav" tag provides more meaning, I guess bootstrap just checks the
class "navbar" so it doesn't care if you used a div or a nav, but in terms
of semantics, a nav tag if better for a navigation bar as the name suggests.

El dom., 22 dic. 2019 a las 20:08, fugee ohu ()
escribió:

> Documentation says to use:
>
> 
> But in my views I've been using
>  
> The code is a little different, I have to try it out, but the question is the 
> same Is applying the class to the div the same as not using the div for 
> bootstrap purposes
>
> --
> You received this message because you are subscribed 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/f79a4675-30bd-4527-872f-f65badb78d5b%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/CAPS3bcCjNGeViMEWg54Mk7VO-DuDORUsZc%3DpTg2wA94s9UaSWg%40mail.gmail.com.


Re: [Rails] rails 6 where to put javascript files

2019-12-22 Thread Ariel Juodziukynas
There's a section specifying where to put js files on the documentation
https://github.com/rails/webpacker#paths. You can put the files anywhere,
if you put them inside the packs folder webpacker will create bundles using
those files, if you put them elsewhere wenpacker will bundle them inside
the packs that require them.

El dom., 22 dic. 2019 a las 4:48, fugee ohu () escribió:

> Where do I put my custom javascript files now, under javascripts or under
> javascripts/packs or should i create a directory like 'custom' under
> javascripts and then in javascript/packs/application.js i would have to
> import "../custom" and that would import all the javascript files in the
> custom directory Can someone please clarify?
>
> --
> You received this message because you are subscribed 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/8295b70b-e09e-4fe3-96ba-cb5017125ace%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/CAPS3bcAG8S4DnZctUV_pVpo7OX5-FPCWHw2cWA6mUf3Wdh1stg%40mail.gmail.com.


Re: [Rails] webpacker images folder

2019-12-22 Thread Ariel Juodziukynas
You shouldn't have files inside pack except for the bundles/packs you'll
link on your html, images go in javacsripts/images, not in
javascripts/packs. Just read the guide
https://github.com/rails/webpacker/blob/master/docs/assets.md#link-in-your-rails-views

El dom., 22 dic. 2019 a las 15:50, fugee ohu ()
escribió:

> If I put in application.js require.context('../images', true) everything
> works fine regardless of whether I place my images folder under javascripts
> or under javascripts/packs If I have my image folder under packs and change
> it to require.context('images', true) it breaks
>
> --
> You received this message because you are subscribed 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/acaa913d-e589-4c10-af28-7488d2777f77%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/CAPS3bcAc3OmGpnT50%3DXCM6gheazpiXypLWpU26ELw1QUXOzYjA%40mail.gmail.com.


Re: [Rails] Re: access images in stylesheets with webpacker and rails 6

2019-12-22 Thread Ariel Juodziukynas
Webpacker provides an `asset_pack_path` method
https://github.com/rails/webpacker#usage

I guess you'll need to use a .css.erb file in order for that to work.

# something.css.erb

.search_button {
  background: url('<%= asset_pack_path('images/search.png') %>');
}

Lately you are asking A LOT of questions about webpacker for images and
CSS, you don't really HAVE to change from Sprockets to Webpacker to update
to rails 6, in fact, if you start a new rails app, it uses webpacker only
for javascript assets, it's still using sprockets for css and images by
default. Of course you are free to use webpacker for everything but maybe
you have to follow webpack guidelines and start messing with loaders, check
the webpack guide on packing images and using it for background image for
example https://webpack.js.org/guides/asset-management/#loading-images

El dom., 22 dic. 2019 a las 17:12, fugee ohu ()
escribió:

> Webpacker is serving images in views, I just don't know how to do it in css
>
> --
> You received this message because you are subscribed 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/549cd10d-f440-4ca0-a3a5-51748c623e92%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/CAPS3bcB9iMN5kwO%2B6VOoQoHuLDi90hzxC9xSt7RUxD45bUXQgA%40mail.gmail.com.


Re: [Rails] No folder under node_modules after install packages with yarn

2019-12-19 Thread Ariel Juodziukynas
Yarn creates the folder on the directory you run that command. Also it's ok
the folder is not inside the packs folder, webpacker creates bundles for
any file inside the packs folder, you shouldn't have files other than the
packs/bundles you'll link on your html.

El jue., 19 dic. 2019 19:47, 'Jake Niemiec' via Ruby on Rails: Talk <
rubyonrails-talk@googlegroups.com> escribió:

> node_modules should be in your root folder. (a sibling of ./app)
>
> On Thu, Dec 19, 2019 at 4:19 PM fugee ohu  wrote:
>
>> I ran `yarn add bootstrap` and there's no bootstrap folder created under
>> app/javascript/packs/node_modules
>>
>> --
>> You received this message because you are subscribed 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/2354730d-7e01-4629-8b7f-6d447e7dd071%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/CALn2xuDUH9X5i54J-t%2BxriHPE%3Dw0GeoBV7CNdG7W5N0v%3DC_4Lg%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/CAPS3bcA%2B2P5uYYtu7vh4-DVYQSjNEVaovCFEErcj06xTZjeP_Q%40mail.gmail.com.


Re: [Rails] How do I use a favicon in rails 6 ?

2019-12-10 Thread Ariel Juodziukynas
What I mean is that you don't really need webpacker for the favicon, you
can just put the favicon.ico file inside app/public and it should work

El mar., 10 dic. 2019 09:53, fugee ohu  escribió:

>
>
> On Monday, December 9, 2019 at 4:58:45 PM UTC-5, Ariel Juodziukynas wrote:
>>
>> Why don't you just put the favicon.ico file on your /public folder? do
>> you have something special to use javascript for this?
>>
>> El lun., 9 dic. 2019 a las 18:51, fugee ohu ()
>> escribió:
>>
>>> I tried creating a favicons folder under app/javascripts/images/favicons
>>> and a favicons.js file in app/javascripts/packs and an import statement in
>>> app/javascripts/packs/application.js to load the favicons.js file but I
>>> just got an error from webpacker that there was no entry in manifest.json
>>> for favicon.ico I had tried to follow the tutorial here
>>> https://medium.com/tech-angels-publications/bundle-your-favicons-with-webpack-b69d834b2f53
>>>
>>> --
>>> You received this message because you are subscribed 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/dbfe8f63-8cc6-41b2-93a6-85a0f3e2a2f4%40googlegroups.com
>>> <https://groups.google.com/d/msgid/rubyonrails-talk/dbfe8f63-8cc6-41b2-93a6-85a0f3e2a2f4%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>>
> I don't know Can you look at the page and tell me if it works for 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/bf34e030-ddfa-420c-b0f2-79105547c9ba%40googlegroups.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/bf34e030-ddfa-420c-b0f2-79105547c9ba%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
You received this message because you are subscribed 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/CAPS3bcCACePp818h90e_RmcCbY3z6ND4wttS_%2B0THVsr-xn5nA%40mail.gmail.com.


Re: [Rails] How do I use a favicon in rails 6 ?

2019-12-09 Thread Ariel Juodziukynas
Why don't you just put the favicon.ico file on your /public folder? do you
have something special to use javascript for this?

El lun., 9 dic. 2019 a las 18:51, fugee ohu () escribió:

> I tried creating a favicons folder under app/javascripts/images/favicons
> and a favicons.js file in app/javascripts/packs and an import statement in
> app/javascripts/packs/application.js to load the favicons.js file but I
> just got an error from webpacker that there was no entry in manifest.json
> for favicon.ico I had tried to follow the tutorial here
> https://medium.com/tech-angels-publications/bundle-your-favicons-with-webpack-b69d834b2f53
>
> --
> You received this message because you are subscribed 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/dbfe8f63-8cc6-41b2-93a6-85a0f3e2a2f4%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/CAPS3bcCoWFewERBEw1%3DNe7fB9%2BWq9_3%2BScTimCMJQuL1gEjPbw%40mail.gmail.com.


Re: [Rails] snippet duplicates fields x 8

2019-12-05 Thread Ariel Juodziukynas
I'm sorry, it's "iip.object.item_proerty_id", you have to get the object
from the iip form builder

El jue., 5 dic. 2019 a las 12:23, fugee ohu () escribió:

>
>
> On Thursday, December 5, 2019 at 7:29:42 AM UTC-5, Ariel Juodziukynas
> wrote:
>>
>> I'm not really sure what's your intention and what's the state of
>> the @item instance. And I have to admit your namings are really confusing
>> "item.item_item_properties" looks too repetitive, are `iip` and
>> `item_item_property` on both loops the same class? does @item have all the
>> item_item_properties?
>>
>> I think I would do
>>
>> <%= f.fields_for :item_item_properties do |iip| %>
>>   
>> <%= iip.label iip.item_property.name
>> <http://item_item_property.item_property.name/> %>
>> <%= iip.hidden_field :item_property_id, value: iip.item_property_id
>> %>
>> <%= iip.text_field  :text_value, value: iip.text_value %>
>>   
>> <% end %>
>>
>> But I'm not sure that's your intention.
>>
>> Also, a TD inside a DIV is not valid HTML, it will brake your template
>>
>>
>> El jue., 5 dic. 2019 a las 8:04, fugee ohu ()
>> escribió:
>>
>>>
>>>
>>> On Wednesday, December 4, 2019 at 3:39:35 PM UTC-5, Ariel Juodziukynas
>>> wrote:
>>>>
>>>> Your form_for uses the @item? if so you are already looping through
>>>> it's item_item_properties, yo don't need to loop again inside fields_for,
>>>> you already have iip defined, that's why you have everything multiplied
>>>>
>>>> El mié., 4 dic. 2019 a las 11:55, fugee ohu ()
>>>> escribió:
>>>>
>>>>> This snippet duplicates all the expected fields times 8
>>>>>
>>>>><%= f.fields_for :item_item_properties do |iip| %>
>>>>>   
>>>>>   <% @item.item_item_properties.each do
>>>>> |item_item_property| %>
>>>>> <%= iip.label
>>>>> item_item_property.item_property.name %><%= iip.hidden_field
>>>>> :item_property_id, value: item_item_property.item_property_id %> <%=
>>>>> iip.text_field  :text_value, value: item_item_property.text_value %>
>>>>>  <% end %>
>>>>>   
>>>>> <% end %>
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Ruby on Rails: Talk" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to rubyonra...@googlegroups.com.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/rubyonrails-talk/f72416d0-72cd-48b4-a6b1-13a55909d59f%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/rubyonrails-talk/f72416d0-72cd-48b4-a6b1-13a55909d59f%40googlegroups.com?utm_medium=email_source=footer>
>>>>> .
>>>>>
>>>>
>>> Can you please show me how you would re-write the code block using the
>>> magical iteration of @item
>>>
>>> --
>>> You received this message because you are subscribed 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/54a65988-5012-4c85-99be-43a4380e2710%40googlegroups.com
>>> <https://groups.google.com/d/msgid/rubyonrails-talk/54a65988-5012-4c85-99be-43a4380e2710%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>>
> Yes that's what I'm doing but I get the error
> ActionView::Template::Error (undefined method `item_property_id' for
> #):
> 32:
> 33:
> 34: <%= f.fields_for :item_item_properties do |iip| %>
> 35: <%= iip.label
> ItemProperty.find(iip.item_property_id).name %><%= iip.hidden_field
> :item_property_id, value: iip.item_property_id %> <%= iip.text_field
> :text_value, value: iip.text_value %>
> 36: <% end %>
> 37:
> 38: <%= f.label :box_id %>
>
> app/views/items/_form.html.erb:35:in `block (2 levels) in
> _app_views_it

Re: [Rails] snippet duplicates fields x 8

2019-12-05 Thread Ariel Juodziukynas
I'm not really sure what's your intention and what's the state of the @item
instance. And I have to admit your namings are really confusing
"item.item_item_properties" looks too repetitive, are `iip` and
`item_item_property` on both loops the same class? does @item have all the
item_item_properties?

I think I would do

<%= f.fields_for :item_item_properties do |iip| %>
  
<%= iip.label iip.item_property.name
<http://item_item_property.item_property.name/> %>
<%= iip.hidden_field :item_property_id, value: iip.item_property_id %>
<%= iip.text_field  :text_value, value: iip.text_value %>
  
<% end %>

But I'm not sure that's your intention.

Also, a TD inside a DIV is not valid HTML, it will brake your template


El jue., 5 dic. 2019 a las 8:04, fugee ohu () escribió:

>
>
> On Wednesday, December 4, 2019 at 3:39:35 PM UTC-5, Ariel Juodziukynas
> wrote:
>>
>> Your form_for uses the @item? if so you are already looping through it's
>> item_item_properties, yo don't need to loop again inside fields_for, you
>> already have iip defined, that's why you have everything multiplied
>>
>> El mié., 4 dic. 2019 a las 11:55, fugee ohu ()
>> escribió:
>>
>>> This snippet duplicates all the expected fields times 8
>>>
>>><%= f.fields_for :item_item_properties do |iip| %>
>>>   
>>>   <% @item.item_item_properties.each do
>>> |item_item_property| %>
>>> <%= iip.label
>>> item_item_property.item_property.name %><%= iip.hidden_field
>>> :item_property_id, value: item_item_property.item_property_id %> <%=
>>> iip.text_field  :text_value, value: item_item_property.text_value %>
>>>  <% end %>
>>>   
>>> <% end %>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ruby on Rails: Talk" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to rubyonra...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/rubyonrails-talk/f72416d0-72cd-48b4-a6b1-13a55909d59f%40googlegroups.com
>>> <https://groups.google.com/d/msgid/rubyonrails-talk/f72416d0-72cd-48b4-a6b1-13a55909d59f%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>>
> Can you please show me how you would re-write the code block using the
> magical iteration of @item
>
> --
> You received this message because you are subscribed 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/54a65988-5012-4c85-99be-43a4380e2710%40googlegroups.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/54a65988-5012-4c85-99be-43a4380e2710%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
You received this message because you are subscribed 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/CAPS3bcB-mo2A6W-ET1-QpaVWOWdRm%2Bxc%2BbpHsf_SNbSiUU%3DXAg%40mail.gmail.com.


Re: [Rails] snippet duplicates fields x 8

2019-12-04 Thread Ariel Juodziukynas
Your form_for uses the @item? if so you are already looping through it's
item_item_properties, yo don't need to loop again inside fields_for, you
already have iip defined, that's why you have everything multiplied

El mié., 4 dic. 2019 a las 11:55, fugee ohu () escribió:

> This snippet duplicates all the expected fields times 8
>
><%= f.fields_for :item_item_properties do |iip| %>
>   
>   <% @item.item_item_properties.each do
> |item_item_property| %>
> <%= iip.label
> item_item_property.item_property.name %><%= iip.hidden_field
> :item_property_id, value: item_item_property.item_property_id %> <%=
> iip.text_field  :text_value, value: item_item_property.text_value %>
>  <% end %>
>   
> <% end %>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/f72416d0-72cd-48b4-a6b1-13a55909d59f%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/CAPS3bcA_PbX-ds_Z7i9FW%3DzaiS_1_eX7-FM7%3DDYa9h0bwOBvjw%40mail.gmail.com.


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

2019-12-01 Thread Ariel Juodziukynas
I don't think it's a secret, I guess it's right there in the form_with
documentation

El lun., 2 dic. 2019 01:57, fugee ohu  escribió:

>
>
> On Sunday, December 1, 2019 at 11:04:01 PM UTC-5, Walter Lee Davis wrote:
>>
>>
>>
>> > 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
>>
> Thanks Walter Like  Ariel said, form_with does an ajax request by default
> unless you add 'local: true' I don't know how they keep that a secret
>
> --
> You received this message because you are subscribed 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/e922a2fb-4118-41c4-b719-4f98bda7d1e7%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 

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

2019-12-01 Thread Ariel Juodziukynas
Form_with does an ajax request by default, use form_for or add local: true
as an option or respond with a js view.

El lun., 2 dic. 2019 00:43, fugee ohu  escribió:

>
>
> On Sunday, December 1, 2019 at 7:12:18 PM UTC-5, Walter Lee Davis wrote:
>>
>> 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 rubyonra...@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.
>>
>>
>>
> Strangely the log shows it rendered the form but the page doesn't change
> in the browser as if nothing happened when I clicked the submit button on
> the index page
>   Rendered items/_form.html.erb (34.5ms)
>
> --
> You received this message because you are subscribed 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/f853922b-b6a3-4b25-a909-bd319967c91f%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to 

Re: [Rails] form not loading for get request

2019-12-01 Thread Ariel Juodziukynas
What's your log level value? make sure it's "debug" on your environment
https://guides.rubyonrails.org/debugging_rails_applications.html#log-levels

El dom., 1 dic. 2019 a las 10:30, fugee ohu () escribió:

>
>
> On Saturday, November 30, 2019 at 9:01:50 PM UTC-5, Ariel Juodziukynas
> wrote:
>>
>> The form looks ok, the parameters on the request too, it's impossible to
>> tell you something else if you have nothing on the logs (rails and the
>> browser's network tab) that could indicate an error
>>
>> El sáb., 30 nov. 2019 a las 22:37, fugee ohu ()
>> escribió:
>>
>>>  I guess I'd better explain the form I just posted is from the index
>>> view and on submit it's supposed to launch the new action and load the next
>>> 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/a4caf763-b02f-4d25-980d-a55310a55fa1%40googlegroups.com
>>> <https://groups.google.com/d/msgid/rubyonrails-talk/a4caf763-b02f-4d25-980d-a55310a55fa1%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>>
> It gets a 500 response
> 127.0.0.1 - - [01/Dec/2019:08:25:49 EST] "GET
> /items/new?utf8=%E2%9C%93%5Bitem_type_id%5D=1=New+item
> HTTP/1.1" 500 0
> http://localhost:3000/items ->
> /items/new?utf8=%E2%9C%93%5Bitem_type_id%5D=1=New+item
> How do I find the error?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/77108a16-3395-4562-aabd-dbd77d8f80ee%40googlegroups.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/77108a16-3395-4562-aabd-dbd77d8f80ee%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
You received this message because you are subscribed 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/CAPS3bcDi802tvaQeJ86XBxawDVCxPKeTxtP5iyT-xznKxSWrPA%40mail.gmail.com.


Re: [Rails] form not loading for get request

2019-11-30 Thread Ariel Juodziukynas
The form looks ok, the parameters on the request too, it's impossible to
tell you something else if you have nothing on the logs (rails and the
browser's network tab) that could indicate an error

El sáb., 30 nov. 2019 a las 22:37, fugee ohu ()
escribió:

>  I guess I'd better explain the form I just posted is from the index view
> and on submit it's supposed to launch the new action and load the next 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/a4caf763-b02f-4d25-980d-a55310a55fa1%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/CAPS3bcAFq6bYGXXg8aBx--CE_meVq5vwB24pgq1QXyJwrK5-nA%40mail.gmail.com.


Re: [Rails] form not loading for get request

2019-11-30 Thread Ariel Juodziukynas
It's normal that rails adds a hidden field with the name `utf8` and a check
as the value, when you submit a form using GET the hidden field goes there
with the other fields, there's nothing wrong there.

You should have some error on the console if something is not working, that
`utf8` parameter is ok.

El sáb., 30 nov. 2019 a las 20:28, fugee ohu ()
escribió:

> This request has some utf8 in between "item_type_id" and "="
> GET /items/new?utf8=%E2%9C%93%5Bitem_type_id%5D=9=New+item
> HTTP/1.1
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/4e4ee2a6-e656-4dd2-84f0-670f9eaa40b0%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/CAPS3bcBFxS92d6-28qdRmXg%3DQDR_vVA7-pzFFw5Ux7Uf3x6KjQ%40mail.gmail.com.


Re: [Rails] How do I load schema in rails 6

2019-11-29 Thread Ariel Juodziukynas
What do you mean that you have an error en your schema.rb? When you run a
migration, rails dumps the current database schema (rails db:schema:dump).
Maybe you have some merge conflict if you are using source control and
someone fixed the conflict wrong, but the file shouldn't have errors since
it's just a dump of the actual running database's schema.

You have all the db: tasks (run `rails -T | grep 'db:' to list all)
including running the migrations, those are the only commands to change
your database schema using rails.

El vie., 29 nov. 2019 a las 7:11, fugee ohu () escribió:

>
>
> On Tuesday, November 26, 2019 at 9:37:54 AM UTC-5, Ariel Juodziukynas
> wrote:
>>
>> You were trying to reload the schema, db:schema:load requires an empty
>> database, I guessed you were OK with removing the data. db:reset it's just
>> a shortcut for drop > create > schema:load > seed.
>>
>> Why do you want to load the schema if you already have data and you don't
>> want to lose it? that makes no sense, if you already have data then you
>> already have the schema loaded.
>>
>> El mar., 26 nov. 2019 a las 10:59, Hasan Diwan ()
>> escribió:
>>
>>> [response inline]
>>>
>>>
>>> On Tue, 26 Nov 2019 at 05:55, fugee ohu  wrote:
>>>
>>>> What would that do to my data
>>>>
>>>
>>> You'll need to back it up. Which database are you using? -- H
>>> --
>>> OpenPGP:
>>> https://sks-keyservers.net/pks/lookup?op=get=0xFEBAD7FFD041BBA1
>>> If you wish to request my time, please do so using 
>>> *bit.ly/hd1AppointmentRequest
>>> <http://bit.ly/hd1AppointmentRequest>*.
>>> Si vous voudrais faire connnaisance, allez a *bit.ly/hd1AppointmentRequest
>>> <http://bit.ly/hd1AppointmentRequest>*.
>>>
>>> <https://sks-keyservers.net/pks/lookup?op=get=0xFEBAD7FFD041BBA1>Sent
>>> from my mobile device
>>> Envoye de mon portable
>>>
>>> --
>>> You received this message because you are subscribed 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/CAP%2BbYWAGfMrun5ZYzUuJRbbxx24-o3iKZfKSBv%3DEx52nA3fRkA%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/rubyonrails-talk/CAP%2BbYWAGfMrun5ZYzUuJRbbxx24-o3iKZfKSBv%3DEx52nA3fRkA%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>>
>>
> Yes right There's no data I was just curious about the db:reset command
> because I never heard of it before I thought there's no possiblity for an
> error in schema.rb How can I have an error in my schema.rb I'm thinking
> maybe there's a new way to load the schema in rails 6 I created the
> database and tried to load the schema
>
> --
> You received this message because you are subscribed 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/ab1850ac-9086-41de-a700-3419637f9aba%40googlegroups.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/ab1850ac-9086-41de-a700-3419637f9aba%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
You received this message because you are subscribed 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/CAPS3bcDH%3D_BCnQpVCYoT1WZDpwqXhOpQkp26CBeU3zUfqxL78g%40mail.gmail.com.


Re: [Rails] How do I load schema in rails 6

2019-11-26 Thread Ariel Juodziukynas
You were trying to reload the schema, db:schema:load requires an empty
database, I guessed you were OK with removing the data. db:reset it's just
a shortcut for drop > create > schema:load > seed.

Why do you want to load the schema if you already have data and you don't
want to lose it? that makes no sense, if you already have data then you
already have the schema loaded.

El mar., 26 nov. 2019 a las 10:59, Hasan Diwan ()
escribió:

> [response inline]
>
>
> On Tue, 26 Nov 2019 at 05:55, fugee ohu  wrote:
>
>> What would that do to my data
>>
>
> You'll need to back it up. Which database are you using? -- H
> --
> OpenPGP:
> https://sks-keyservers.net/pks/lookup?op=get=0xFEBAD7FFD041BBA1
> If you wish to request my time, please do so using 
> *bit.ly/hd1AppointmentRequest
> *.
> Si vous voudrais faire connnaisance, allez a *bit.ly/hd1AppointmentRequest
> *.
>
> Sent
> from my mobile device
> Envoye de mon portable
>
> --
> You received this message because you are subscribed 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/CAP%2BbYWAGfMrun5ZYzUuJRbbxx24-o3iKZfKSBv%3DEx52nA3fRkA%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/CAPS3bcBChEKx51UOE_-g9Xc-UnnfL0HaBkrevL_%3DmyQ9Bfng7Q%40mail.gmail.com.


Re: [Rails] How do I load schema in rails 6

2019-11-26 Thread Ariel Juodziukynas
You can run rails db:reset then

El mar., 26 nov. 2019 05:37, Hasan Diwan  escribió:

> [response inline]
>
> On Tue, 26 Nov 2019 at 00:00, fugee ohu  wrote:
>
>> Complains that users table already exists
>>
>
> bundle exec rails db:drop db:create db:migrate db:schema:load
>
> Seems you had a mistake in a migration. So, you need to reset your
> database to pristine state and start again. Hope this helps! -- H
>
> --
> OpenPGP:
> https://sks-keyservers.net/pks/lookup?op=get=0xFEBAD7FFD041BBA1
> If you wish to request my time, please do so using 
> *bit.ly/hd1AppointmentRequest
> *.
> Si vous voudrais faire connnaisance, allez a *bit.ly/hd1AppointmentRequest
> *.
>
> Sent
> from my mobile device
> Envoye de mon portable
>
> --
> You received this message because you are subscribed 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/CAP%2BbYWDPz0-BRfO5ohk%3DT76WKCb6JYhyqudqzqznnEBcQ0eOkQ%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/CAPS3bcDSv9nTPNNmz3cjdXy4eLDB2ZU9%2B1LLz0-DVS6QV-PWGg%40mail.gmail.com.


Re: [Rails] How do I load schema in rails 6

2019-11-25 Thread Ariel Juodziukynas
It is `rails db:schema:load`, run `rails -T` to list all the available
tasks.

El lun., 25 nov. 2019 a las 23:13, fugee ohu ()
escribió:

> Is there a new command to load the schema in rails 6?
>
> --
> You received this message because you are subscribed 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/a77d507f-2927-4e38-8f88-643e8e24030f%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/CAPS3bcAzgfHGM03nmXbrF%3D3bOOLh313EWSzVCrg6YTaNDPoJGw%40mail.gmail.com.


Re: [Rails] sass-rails

2019-11-23 Thread Ariel Juodziukynas
sass/scss files shouldn't be linked by your website, these files have to be
compiled into standard .css files with sprockets, webpacker or any other
sass compiler.

Usually, if you use sass-rails (or sassc-rails on newer rails version) or
webpacker, both gems should take care of compiling the assets for you with
proper configuration.

El sáb., 23 nov. 2019 a las 20:30, fugee ohu ()
escribió:

> What's supposed to cause rails to take application to mean
> application.scss ? The problem I'm having is my stylesheet is named
> application.scss and rails is looking for application.css If I name it as
> application.scss in stylesheet_link_tag then it looks for
> application.css.scss
>
> --
> You received this message because you are subscribed 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/74428116-1c8a-47b3-97e2-ee49a0c05696%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/CAPS3bcAxFW82xM-QCQyXGONWoVGWxVK%3Da97RSfCPc0q%3Dm3aAVA%40mail.gmail.com.


Re: [Rails] where do i put rails 6 stylesheets

2019-11-23 Thread Ariel Juodziukynas
Rails 6 supports both sprockets (the assets pipeline) and webpacker by
default, you can use any of those. You can use app/assets/stylesheets as of
previous rails versions that didn't have webpacker or you can follow
webacker's readme on CSS
https://github.com/rails/webpacker/blob/master/docs/css.md

El sáb., 23 nov. 2019 a las 19:44, Hasan Diwan ()
escribió:

> app/assets/stylesheets/
>
>
>
> Try that spot? -- H
>
> --
> You received this message because you are subscribed 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/CAP%2BbYWBP9C3Bn087ZMfyeYo097R3DAjND-A_nbmjvOv-%2BY1DfQ%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/CAPS3bcCrG0sNV5dtyDOeohzKGxQGJEXk-G0L0WLx9VO9ovqB0g%40mail.gmail.com.


Re: [Rails] app/javascripts/packs ?

2019-11-23 Thread Ariel Juodziukynas
yes, you can delete them

El sáb., 23 nov. 2019 a las 13:05, fugee ohu ()
escribió:

> Thanks, Delete all files from public/packs/js for a clean start?
>
> --
> You received this message because you are subscribed 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/fe484a00-4e17-43ea-a5c3-575372c1ad13%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/CAPS3bcDod1cY6VUEcjJj_16HHk5O2mdacWbKcHwmrSdB4i%2BAtA%40mail.gmail.com.


Re: [Rails] app/javascripts/packs ?

2019-11-23 Thread Ariel Juodziukynas
you develop inside /app/javascript/pack, webpacker compiles the js in
/public/packs

El sáb., 23 nov. 2019 a las 11:50, fugee ohu ()
escribió:

> I read somewhere when adding webpacker to an existing rails app I'd have
> this directory app/javascripts/packs but in rails 6 I think it's supposed
> to be /public/packs What's the right path to 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/85d70f5b-da09-4bdc-a767-8e1fff408a71%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/CAPS3bcBUPfOy4GeXikveAjEZag26e18g5wvFitph3LdnpPa7qw%40mail.gmail.com.


Re: [Rails] build with nested forms

2019-11-02 Thread Ariel Juodziukynas
@item.item_item_properties.item_property_id is wrong,
@item.item_item_properties is a collection, use `
iip.object.item_property.name` and `iip.object.item_property_id` instead.

imagine @item.item_item_properties is something like an array
[item_item_property1, item_item_property2], you can't call
`item_property_id` on an array, you have to call it on one of the items
inside it, and that "iip" variable, if you call `.object` on it you get
that item from within the array.

El sáb., 2 nov. 2019 a las 4:38, fugee ohu () escribió:

> The I'm getting error is
>
> undefined method `item_property_id' for 
> #
>
>
>   def new
> @item = Item.new(item_params)
> ItemProperty.where(item_type: params[:item][:item_type]).each do
> |ip|
> @item.item_item_properties.build(item_property_id: ip.id)
> end
>   end
>
>
> <%= f.fields_for :item_item_properties do |iip| %>
>   
>   <%= iip.label
> "#{ItemProperty.find(@item.item_item_properties.item_property_id).name}"
> %>  <%= iip.hidden_field :item_property_id, value:
> @item.item_item_properties.item_property_id %> <%= iip.text_field
> :text_value %>
>   
> <% end %>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/98eed4a3-d1dc-4a3e-a0af-058d0f10740b%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/CAPS3bcB%2BXNyGzA%3D9sq2rDCc_TVvm3rOdjXoLNuiSxC%3DubH8p3g%40mail.gmail.com.


Re: [Rails] build method and nested forms

2019-11-02 Thread Ariel Juodziukynas
What do you mean that "pet's attributes can't be found"? found where? how?
show the code that doesn't work for you.

El sáb., 2 nov. 2019 a las 4:30, fugee ohu () escribió:

> if i  @users.pets.build then in my form I'll have  <%= f.fields_for :pets
> do |pet| %> will iterate the same number of times as @user.pets.size but
> pet's attributes can't be found in :pet although they're available in
> @users.pets.attributes So I have to use : and @ together in the same form
> to display values from the object created in the controller by build?
>
> --
> You received this message because you are subscribed 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/8995111c-edd7-4047-a75e-0f62b2a464ae%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/CAPS3bcCK4HX_ePV4F71NvC%3D5kxqcnT9VJSbHYSPA6G_s_e7NSA%40mail.gmail.com.


Re: [Rails] need help with carrierwave - multiple vs single file upload

2019-11-01 Thread Ariel Juodziukynas
If you need extra fields for each attachment then you need an extra model
to store that data and the carrierwave file for each file you upload. Given
the name of the model "FolderAttachment" it looks like that's the model and
that it shouldn't have multiple files, it looks like there should be
multiple FolderAttachments with only one file each.

El vie., 1 nov. 2019 a las 14:55, tom () escribió:

> usecase:
> if i do multiupload, how could i add comments and additional fields to
> 'each' file during upload!?
>
>
>
> On Fri, Nov 1, 2019 at 1:53 PM Ariel Juodziukynas 
> wrote:
>
>> I don't think you can use the same attribute name for single and multiple
>> attachments at the same time. What you can do is to always have multiple
>> files and attach only one file when you get a single file upload. I don't
>> understand the use case of your idea.
>>
>> El vie., 1 nov. 2019 a las 14:41, tom () escribió:
>>
>>> yep - its working.
>>> but, can i get the array of filenames in case of multiupload in to the
>>> same db field and or vice versa? eg:
>>>
>>> mount_uploader  :files, FolderAttachmentUploader
>>> mount_uploaders  :files, FolderAttachmentUploader
>>>
>>>
>>> On Fri, Nov 1, 2019 at 1:30 PM Ariel Juodziukynas 
>>> wrote:
>>>
>>>> I think your problem is here
>>>>
>>>> <%= form.file_field :files, multiple: true, name:
>>>> "folder_attachments[files][]"  %>
>>>>
>>>> use "folder_attachment[files][]", note "folder_attachment" singular,
>>>> not plural since the form is for a single folder_attachment (and that's on
>>>> your folder_attachment_params method)
>>>>
>>>> El vie., 1 nov. 2019 a las 14:19, tom () escribió:
>>>>
>>>>> ok, the plural got me beyond an error message, but i cant see the
>>>>> uploaded multiuploaded files. singles files work.
>>>>>
>>>>> controller code:
>>>>> @folder_attachment = FolderAttachment.new(folder_attachment_params)
>>>>> @folder_attachment.company_id = current_user.cid
>>>>> @folder_attachment.user_id = current_user.id
>>>>>
>>>>>
>>>>> @folder =
>>>>> Folder.find_by_id(params[:folder_attachment][:folder_id])
>>>>>
>>>>> respond_to do |format|
>>>>>   if @folder_attachment.save
>>>>> format.html { redirect_to @folder , notice: 'Attachment was
>>>>> successfully created.' }
>>>>>   #  format.json { render :show, status: :created, location:
>>>>> @folder_attachment }
>>>>>   else
>>>>> format.html { render :new }
>>>>># format.json { render json: @folder_attachment.errors, status:
>>>>> :unprocessable_entity }
>>>>>   end
>>>>> end
>>>>>
>>>>>
>>>>> def folder_attachment_params
>>>>>   params.require(:folder_attachment).permit(:company_id,
>>>>> :folder_id, :singlefile, :comment,:tags, {files: []})
>>>>> end
>>>>> ==
>>>>> class FolderAttachmentUploader < CarrierWave::Uploader::Base
>>>>>   # Include RMagick or MiniMagick support:
>>>>>   # include CarrierWave::RMagick
>>>>>   # include CarrierWave::MiniMagick
>>>>>
>>>>>   # Choose what kind of storage to use for this uploader:
>>>>>   storage :file
>>>>>
>>>>>   # storage :fog
>>>>>
>>>>>   # Override the directory where uploaded files will be stored.
>>>>>   # This is a sensible default for uploaders that are meant to be
>>>>> mounted:
>>>>>   def store_dir
>>>>> "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
>>>>>   end
>>>>>
>>>>>
>>>>>
>>>>> any ideas?
>>>>>
>>>>> thx
>>>>>
>>>>>
>>>>>
>>>>> On Fri, Nov 1, 2019 at 12:24 PM Ariel Juodziukynas <
>>>>> arielj...@gmail.com> wrote:
>>>>>
>>>>>> Also, use "mount_uploader" singular for the single file and
>>>>>> "mount_uploaders" plural for the multiple files
>>>>>>
>>

Re: [Rails] need help with carrierwave - multiple vs single file upload

2019-11-01 Thread Ariel Juodziukynas
I mean: multiple files can be zero or more, it includes the possibility of
having only 1 file attached.

El vie., 1 nov. 2019 a las 14:53, Ariel Juodziukynas ()
escribió:

> I don't think you can use the same attribute name for single and multiple
> attachments at the same time. What you can do is to always have multiple
> files and attach only one file when you get a single file upload. I don't
> understand the use case of your idea.
>
> El vie., 1 nov. 2019 a las 14:41, tom () escribió:
>
>> yep - its working.
>> but, can i get the array of filenames in case of multiupload in to the
>> same db field and or vice versa? eg:
>>
>> mount_uploader  :files, FolderAttachmentUploader
>> mount_uploaders  :files, FolderAttachmentUploader
>>
>>
>> On Fri, Nov 1, 2019 at 1:30 PM Ariel Juodziukynas 
>> wrote:
>>
>>> I think your problem is here
>>>
>>> <%= form.file_field :files, multiple: true, name:
>>> "folder_attachments[files][]"  %>
>>>
>>> use "folder_attachment[files][]", note "folder_attachment" singular, not
>>> plural since the form is for a single folder_attachment (and that's on your
>>> folder_attachment_params method)
>>>
>>> El vie., 1 nov. 2019 a las 14:19, tom () escribió:
>>>
>>>> ok, the plural got me beyond an error message, but i cant see the
>>>> uploaded multiuploaded files. singles files work.
>>>>
>>>> controller code:
>>>> @folder_attachment = FolderAttachment.new(folder_attachment_params)
>>>> @folder_attachment.company_id = current_user.cid
>>>> @folder_attachment.user_id = current_user.id
>>>>
>>>>
>>>> @folder = Folder.find_by_id(params[:folder_attachment][:folder_id])
>>>>
>>>> respond_to do |format|
>>>>   if @folder_attachment.save
>>>> format.html { redirect_to @folder , notice: 'Attachment was
>>>> successfully created.' }
>>>>   #  format.json { render :show, status: :created, location:
>>>> @folder_attachment }
>>>>   else
>>>> format.html { render :new }
>>>># format.json { render json: @folder_attachment.errors, status:
>>>> :unprocessable_entity }
>>>>   end
>>>> end
>>>>
>>>>
>>>> def folder_attachment_params
>>>>   params.require(:folder_attachment).permit(:company_id,
>>>> :folder_id, :singlefile, :comment,:tags, {files: []})
>>>> end
>>>> ==
>>>> class FolderAttachmentUploader < CarrierWave::Uploader::Base
>>>>   # Include RMagick or MiniMagick support:
>>>>   # include CarrierWave::RMagick
>>>>   # include CarrierWave::MiniMagick
>>>>
>>>>   # Choose what kind of storage to use for this uploader:
>>>>   storage :file
>>>>
>>>>   # storage :fog
>>>>
>>>>   # Override the directory where uploaded files will be stored.
>>>>   # This is a sensible default for uploaders that are meant to be
>>>> mounted:
>>>>   def store_dir
>>>> "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
>>>>   end
>>>>
>>>>
>>>>
>>>> any ideas?
>>>>
>>>> thx
>>>>
>>>>
>>>>
>>>> On Fri, Nov 1, 2019 at 12:24 PM Ariel Juodziukynas 
>>>> wrote:
>>>>
>>>>> Also, use "mount_uploader" singular for the single file and
>>>>> "mount_uploaders" plural for the multiple files
>>>>>
>>>>> El vie., 1 nov. 2019 a las 12:44, tom ()
>>>>> escribió:
>>>>>
>>>>>> hi,
>>>>>>
>>>>>> i want to have one uploader, but 2 forms:
>>>>>>
>>>>>> Upload Single Attachment
>>>>>> <%= simple_form_for(FolderAttachment.new) do |form| %>
>>>>>>   <%= form.error_notification %>
>>>>>>
>>>>>>   
>>>>>>   <%= form.file_field :singlefile %>
>>>>>>   
>>>>>>
>>>>>>   <%= form.input :folder_id , :as => :hidden , :input_html => {
>>>>>> :value => @folder_current.id}  if @folder_current %>
>>>>>>
>>>>>>  

Re: [Rails] need help with carrierwave - multiple vs single file upload

2019-11-01 Thread Ariel Juodziukynas
I don't think you can use the same attribute name for single and multiple
attachments at the same time. What you can do is to always have multiple
files and attach only one file when you get a single file upload. I don't
understand the use case of your idea.

El vie., 1 nov. 2019 a las 14:41, tom () escribió:

> yep - its working.
> but, can i get the array of filenames in case of multiupload in to the
> same db field and or vice versa? eg:
>
> mount_uploader  :files, FolderAttachmentUploader
> mount_uploaders  :files, FolderAttachmentUploader
>
>
> On Fri, Nov 1, 2019 at 1:30 PM Ariel Juodziukynas 
> wrote:
>
>> I think your problem is here
>>
>> <%= form.file_field :files, multiple: true, name:
>> "folder_attachments[files][]"  %>
>>
>> use "folder_attachment[files][]", note "folder_attachment" singular, not
>> plural since the form is for a single folder_attachment (and that's on your
>> folder_attachment_params method)
>>
>> El vie., 1 nov. 2019 a las 14:19, tom () escribió:
>>
>>> ok, the plural got me beyond an error message, but i cant see the
>>> uploaded multiuploaded files. singles files work.
>>>
>>> controller code:
>>> @folder_attachment = FolderAttachment.new(folder_attachment_params)
>>> @folder_attachment.company_id = current_user.cid
>>> @folder_attachment.user_id = current_user.id
>>>
>>>
>>> @folder = Folder.find_by_id(params[:folder_attachment][:folder_id])
>>>
>>> respond_to do |format|
>>>   if @folder_attachment.save
>>> format.html { redirect_to @folder , notice: 'Attachment was
>>> successfully created.' }
>>>   #  format.json { render :show, status: :created, location:
>>> @folder_attachment }
>>>   else
>>> format.html { render :new }
>>># format.json { render json: @folder_attachment.errors, status:
>>> :unprocessable_entity }
>>>   end
>>> end
>>>
>>>
>>> def folder_attachment_params
>>>   params.require(:folder_attachment).permit(:company_id, :folder_id,
>>> :singlefile, :comment,:tags, {files: []})
>>> end
>>> ==
>>> class FolderAttachmentUploader < CarrierWave::Uploader::Base
>>>   # Include RMagick or MiniMagick support:
>>>   # include CarrierWave::RMagick
>>>   # include CarrierWave::MiniMagick
>>>
>>>   # Choose what kind of storage to use for this uploader:
>>>   storage :file
>>>
>>>   # storage :fog
>>>
>>>   # Override the directory where uploaded files will be stored.
>>>   # This is a sensible default for uploaders that are meant to be
>>> mounted:
>>>   def store_dir
>>> "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
>>>   end
>>>
>>>
>>>
>>> any ideas?
>>>
>>> thx
>>>
>>>
>>>
>>> On Fri, Nov 1, 2019 at 12:24 PM Ariel Juodziukynas 
>>> wrote:
>>>
>>>> Also, use "mount_uploader" singular for the single file and
>>>> "mount_uploaders" plural for the multiple files
>>>>
>>>> El vie., 1 nov. 2019 a las 12:44, tom () escribió:
>>>>
>>>>> hi,
>>>>>
>>>>> i want to have one uploader, but 2 forms:
>>>>>
>>>>> Upload Single Attachment
>>>>> <%= simple_form_for(FolderAttachment.new) do |form| %>
>>>>>   <%= form.error_notification %>
>>>>>
>>>>>   
>>>>>   <%= form.file_field :singlefile %>
>>>>>   
>>>>>
>>>>>   <%= form.input :folder_id , :as => :hidden , :input_html => { :value
>>>>> => @folder_current.id}  if @folder_current %>
>>>>>
>>>>>   
>>>>>   <%= form.input :comment %>
>>>>>   
>>>>>
>>>>>   
>>>>>   <%= form.input :tags %>
>>>>>   
>>>>>
>>>>>
>>>>>   
>>>>> <%= form.button :submit %>
>>>>>   
>>>>> <% end %>
>>>>>
>>>>>
>>>>> Upload Multiple Attachments
>>>>> <%= simple_form_for(FolderAttachment.new, :html => { :multipart =>
>>>>> true } ) do |form| %>
&

Re: [Rails] need help with carrierwave - multiple vs single file upload

2019-11-01 Thread Ariel Juodziukynas
I think your problem is here

<%= form.file_field :files, multiple: true, name:
"folder_attachments[files][]"  %>

use "folder_attachment[files][]", note "folder_attachment" singular, not
plural since the form is for a single folder_attachment (and that's on your
folder_attachment_params method)

El vie., 1 nov. 2019 a las 14:19, tom () escribió:

> ok, the plural got me beyond an error message, but i cant see the uploaded
> multiuploaded files. singles files work.
>
> controller code:
> @folder_attachment = FolderAttachment.new(folder_attachment_params)
> @folder_attachment.company_id = current_user.cid
> @folder_attachment.user_id = current_user.id
>
>
> @folder = Folder.find_by_id(params[:folder_attachment][:folder_id])
>
> respond_to do |format|
>   if @folder_attachment.save
> format.html { redirect_to @folder , notice: 'Attachment was
> successfully created.' }
>   #  format.json { render :show, status: :created, location:
> @folder_attachment }
>   else
> format.html { render :new }
># format.json { render json: @folder_attachment.errors, status:
> :unprocessable_entity }
>   end
> end
>
>
> def folder_attachment_params
>   params.require(:folder_attachment).permit(:company_id, :folder_id,
> :singlefile, :comment,:tags, {files: []})
> end
> ==
> class FolderAttachmentUploader < CarrierWave::Uploader::Base
>   # Include RMagick or MiniMagick support:
>   # include CarrierWave::RMagick
>   # include CarrierWave::MiniMagick
>
>   # Choose what kind of storage to use for this uploader:
>   storage :file
>
>   # storage :fog
>
>   # Override the directory where uploaded files will be stored.
>   # This is a sensible default for uploaders that are meant to be mounted:
>   def store_dir
> "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
>   end
>
>
>
> any ideas?
>
> thx
>
>
>
> On Fri, Nov 1, 2019 at 12:24 PM Ariel Juodziukynas 
> wrote:
>
>> Also, use "mount_uploader" singular for the single file and
>> "mount_uploaders" plural for the multiple files
>>
>> El vie., 1 nov. 2019 a las 12:44, tom () escribió:
>>
>>> hi,
>>>
>>> i want to have one uploader, but 2 forms:
>>>
>>> Upload Single Attachment
>>> <%= simple_form_for(FolderAttachment.new) do |form| %>
>>>   <%= form.error_notification %>
>>>
>>>   
>>>   <%= form.file_field :singlefile %>
>>>   
>>>
>>>   <%= form.input :folder_id , :as => :hidden , :input_html => { :value
>>> => @folder_current.id}  if @folder_current %>
>>>
>>>   
>>>   <%= form.input :comment %>
>>>   
>>>
>>>   
>>>   <%= form.input :tags %>
>>>   
>>>
>>>
>>>   
>>> <%= form.button :submit %>
>>>   
>>> <% end %>
>>>
>>>
>>> Upload Multiple Attachments
>>> <%= simple_form_for(FolderAttachment.new, :html => { :multipart => true
>>> } ) do |form| %>
>>>   <%= form.error_notification %>
>>>
>>>   
>>>   <%= form.file_field :files, multiple: true, name:
>>> "folder_attachments[files][]"  %>
>>>   
>>>
>>>   <%= form.input :folder_id , :as => :hidden , :input_html => { :value
>>> => @folder_current.id}  if @folder_current %>
>>>
>>>   
>>> <%= form.button :submit %>
>>>   
>>> <% end %>
>>>
>>>
>>>
>>> --> no matter what i do, i always get errors on controller leve, eg: map
>>> or others. can an uploader only have 1 mount?
>>>
>>> class FolderAttachment < ApplicationRecord
>>>
>>> belongs_to :folder
>>>
>>>
>>>   mount_uploaders  :singlefile, FolderAttachmentUploader
>>>
>>> mount_uploaders  :files, FolderAttachmentUploader
>>>
>>>
>>>
>>> end
>>>
>>> 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 view this discussion on the web visit
>>> https://groups.google.com/d/msgid/rubyonrails-talk

Re: [Rails] need help with carrierwave - multiple vs single file upload

2019-11-01 Thread Ariel Juodziukynas
Also, use "mount_uploader" singular for the single file and
"mount_uploaders" plural for the multiple files

El vie., 1 nov. 2019 a las 12:44, tom () escribió:

> hi,
>
> i want to have one uploader, but 2 forms:
>
> Upload Single Attachment
> <%= simple_form_for(FolderAttachment.new) do |form| %>
>   <%= form.error_notification %>
>
>   
>   <%= form.file_field :singlefile %>
>   
>
>   <%= form.input :folder_id , :as => :hidden , :input_html => { :value => @
> folder_current.id}  if @folder_current %>
>
>   
>   <%= form.input :comment %>
>   
>
>   
>   <%= form.input :tags %>
>   
>
>
>   
> <%= form.button :submit %>
>   
> <% end %>
>
>
> Upload Multiple Attachments
> <%= simple_form_for(FolderAttachment.new, :html => { :multipart => true }
> ) do |form| %>
>   <%= form.error_notification %>
>
>   
>   <%= form.file_field :files, multiple: true, name:
> "folder_attachments[files][]"  %>
>   
>
>   <%= form.input :folder_id , :as => :hidden , :input_html => { :value => @
> folder_current.id}  if @folder_current %>
>
>   
> <%= form.button :submit %>
>   
> <% end %>
>
>
>
> --> no matter what i do, i always get errors on controller leve, eg: map
> or others. can an uploader only have 1 mount?
>
> class FolderAttachment < ApplicationRecord
>
> belongs_to :folder
>
>
>   mount_uploaders  :singlefile, FolderAttachmentUploader
>
> mount_uploaders  :files, FolderAttachmentUploader
>
>
>
> end
>
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMenWxfarO9dCY%2B1N98tmMQuXtysykGj58tV%2B83pqNUEOA%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/CAPS3bcAAiPoY4kVqg8GscSjDcomSoOwzeXpe%3D%2B7xmu6gNfwSgQ%40mail.gmail.com.


Re: [Rails] need help with carrierwave - multiple vs single file upload

2019-11-01 Thread Ariel Juodziukynas
"always get errors", show the errors then

El vie., 1 nov. 2019 a las 12:44, tom () escribió:

> hi,
>
> i want to have one uploader, but 2 forms:
>
> Upload Single Attachment
> <%= simple_form_for(FolderAttachment.new) do |form| %>
>   <%= form.error_notification %>
>
>   
>   <%= form.file_field :singlefile %>
>   
>
>   <%= form.input :folder_id , :as => :hidden , :input_html => { :value => @
> folder_current.id}  if @folder_current %>
>
>   
>   <%= form.input :comment %>
>   
>
>   
>   <%= form.input :tags %>
>   
>
>
>   
> <%= form.button :submit %>
>   
> <% end %>
>
>
> Upload Multiple Attachments
> <%= simple_form_for(FolderAttachment.new, :html => { :multipart => true }
> ) do |form| %>
>   <%= form.error_notification %>
>
>   
>   <%= form.file_field :files, multiple: true, name:
> "folder_attachments[files][]"  %>
>   
>
>   <%= form.input :folder_id , :as => :hidden , :input_html => { :value => @
> folder_current.id}  if @folder_current %>
>
>   
> <%= form.button :submit %>
>   
> <% end %>
>
>
>
> --> no matter what i do, i always get errors on controller leve, eg: map
> or others. can an uploader only have 1 mount?
>
> class FolderAttachment < ApplicationRecord
>
> belongs_to :folder
>
>
>   mount_uploaders  :singlefile, FolderAttachmentUploader
>
> mount_uploaders  :files, FolderAttachmentUploader
>
>
>
> end
>
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMenWxfarO9dCY%2B1N98tmMQuXtysykGj58tV%2B83pqNUEOA%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/CAPS3bcBWMT3HcLG%2B3%2BN01DfkcRju6Rp5jz%3D%2BaSnyaOZh_XcRCA%40mail.gmail.com.


Re: [Rails] build method

2019-10-31 Thread Ariel Juodziukynas
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
>>>>>>> <https://groups.google.com/d/msgid/rubyonrails-talk/161b90ed-b6b1-4d4d-9f67-fb70f0463621%40googlegroups.com?utm_medium=email_source=footer>
>>>>>>> .
>>>>>>>
>>>>>>
>>>>> 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
>>>>> <https://groups.google.com/d/msgid/rubyonrails-talk/a80b3961-82df-4943-9e5a-adb764d516b7%40googlegroups.com?utm_medium=email_source=footer>
>>>>> .
>>>>>
>>>>
>>> Could I directly access key, value without pluck or otherwise like
>>>  @item.item_item_properties.each do |key, value|

Re: [Rails] build method

2019-10-31 Thread Ariel Juodziukynas
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
>>>>> <https://groups.google.com/d/msgid/rubyonrails-talk/161b90ed-b6b1-4d4d-9f67-fb70f0463621%40googlegroups.com?utm_medium=email_source=footer>
>>>>> .
>>>>>
>>>>
>>> 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
>>> <https://groups.google.com/d/msgid/rubyonrails-talk/a80b3961-82df-4943-9e5a-adb764d516b7%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>>
> 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 rubyonrails-talk+unsubscr...@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
> <https://groups.google.com/d/msgid/rubyonrails-talk/b2057f01-80e0-4816-8893-b783e30159f8%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
You received this message because you are subscribed 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/CAPS3bcCGOC%3DindJPMT0xJGj9EmJ1c7tMLTpP00Vb1nX8wBQuUQ%40mail.gmail.com.


Re: [Rails] build method

2019-10-31 Thread Ariel Juodziukynas
@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
>>> <https://groups.google.com/d/msgid/rubyonrails-talk/161b90ed-b6b1-4d4d-9f67-fb70f0463621%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>>
> 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 rubyonrails-talk+unsubscr...@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
> <https://groups.google.com/d/msgid/rubyonrails-talk/a80b3961-82df-4943-9e5a-adb764d516b7%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
You received this message because you are subscribed 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/CAPS3bcAxtZ4PK3yFBT9EZ%3DeB241Ub488xyePjQnozOkbXXyo0Q%40mail.gmail.com.


Re: [Rails] build method

2019-10-31 Thread Ariel Juodziukynas
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 rubyonrails-talk+unsubscr...@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
> 
> .
>

-- 
You received this message because you are subscribed 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/CAPS3bcC%3Djx6MabXASiB2DXgNMeWdw0TMo%2B%3D979RgfHnoN-rH_Q%40mail.gmail.com.


Re: [Rails] auction site listings table

2019-10-27 Thread Ariel Juodziukynas
Read about the `fields_for` helper on actionview and the
`accepts_nested_attributes_for` macro on activerecord to handle nested
forms (fields_for to create the form, accepts_nested_attributes_for so
activerecord handles the associated objects creation).

https://api.rubyonrails.org/classes/ActionView/Helpers/FormBuilder.html#method-i-fields_for
https://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html#method-i-accepts_nested_attributes_for


El dom., 27 oct. 2019 a las 12:47, fugee ohu ()
escribió:

>
>
> On Monday, September 16, 2019 at 4:31:29 PM UTC-4, Ariel Juodziukynas
> wrote:
>>
>> Personally, I would do this:
>>
>> auctions table
>> (with the basic shared information of all auctions and an "auction type"))
>>
>> properties table
>> property_name (like network, carrier, publisher, etc)
>> auction_type (like cellphone, book, etc)
>>
>> auctions_properties
>> auction_id
>> property_id
>> value
>>
>> That way you can have any number of auction types with any number of
>> specific properties with just 3 tables.
>>
>> Note that the "value" column would be some string variation (VARCHAR,
>> CHAR, TEXT, etc) depending on your needs, maybe you want to redesign it a
>> little if you want to store different types. Like if you want to store an
>> integer (and retrieve an integer) you'll have to save the original type and
>> reparse it (you could use serialization but that requires a TEXT column and
>> maybe you can't use that many space)
>>
>> El lun., 16 sept. 2019 a las 17:19, fugee ohu ()
>> escribió:
>>
>>> I was looking at some auction projects that use a single listings table
>>> for all auctions but I know on auction sites the form will be different for
>>> different types of items like if you're selling a cell phone there'll be a
>>> form field for network, carrier, whatever and if you're selling a book
>>> there'll be form fields for publisher, year of publication,  so they would
>>> have separate tables I assume for books, cell phones, etc? Then how would
>>> they treat them all as one?
>>>
>>> --
>>> You received this message because you are subscribed 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/512f8b73-e3a4-4e74-95e7-4281e7b54821%40googlegroups.com
>>> <https://groups.google.com/d/msgid/rubyonrails-talk/512f8b73-e3a4-4e74-95e7-4281e7b54821%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>>
> How would I collect all the auction_propertes fields on a single form
> since they all represent additional records in the auction_properties table
>
> --
> You received this message because you are subscribed 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/fad5e82f-223a-456f-af18-d1e42529b3f0%40googlegroups.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/fad5e82f-223a-456f-af18-d1e42529b3f0%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
You received this message because you are subscribed 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/CAPS3bcBGacaUbirz6R%3D%2Bhuke2V%2Bkn31Tk_3V7TFQMRf1Ckb1HQ%40mail.gmail.com.


Re: [Rails] has_many_through NameError: uninitialized constant

2019-10-21 Thread Ariel Juodziukynas
ItemItemProperty is wrong, belongs_to association should be singular not
plural: belongs_to :item and belongs_to :item_property

El lun., 21 oct. 2019 08:27, fugee ohu  escribió:

> i=Item.first
> i.item_properties
> NameError: uninitialized constant Item::ItemProperties
>
> class Item < ApplicationRecord
>  has_many :boxes
>  has_many :item_pictures
>  has_many :pictures, through: :item_pictures
>  has_many :item_item_properties, primary_key: 'item_type', foreign_key:
> 'item_type'
>  has_many :item_properties, through: :item_item_properties
>  ITEM_TYPES =  ['General', 'Book', 'Record', 'Magazine', 'Pez dispenser',
> 'CD', 'VHS casette']
>  validates :item_type, inclusion: ITEM_TYPES
>  attr_accessor "Year"
>
> end
>
> class ItemItemProperty < ApplicationRecord
>  belongs_to :items, primary_key: 'item_type', foreign_key: 'item_type'
>  belongs_to :item_properties, primary_key: 'item_type', foreign_key:
> 'item_type'
> end
>
> class ItemProperty < ApplicationRecord
>  has_many :item_item_properties, primary_key: 'item_type', foreign_key:
> 'item_type'
>  has_many :items, through: :item_item_properties
> end
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/065ff213-21fe-4b69-a41c-7966bd82a12c%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/CAPS3bcDnGXb00NWse8cUqW%2B_W2qk84UGXAxnOKZVqMFPdbGoUw%40mail.gmail.com.


Re: [Rails] error using direct path url vs ok when navigating by mouse

2019-10-18 Thread Ariel Juodziukynas
You are using `redirect_to request.referrer` and referrer is nil if you
enter the url by hand.

Use `redirect_back fallback: root_path` instead.

El vie., 18 oct. 2019 a las 22:33, fugee ohu ()
escribió:

>
>
> On Friday, October 18, 2019 at 9:22:09 PM UTC-4, Ariel Juodziukynas wrote:
>>
>> Is the link doing a GET request or a POST request? make sure your route
>> matches GET requests too.
>>
>> El vie., 18 oct. 2019 a las 18:07, Colin Law ()
>> escribió:
>>
>>> On Fri, 18 Oct 2019 at 19:33, fugee ohu  wrote:
>>>
>>>>
>>>>
>>>> On Friday, October 18, 2019 at 5:57:55 AM UTC-4, Colin Law wrote:
>>>>>
>>>>> On Fri, 18 Oct 2019 at 09:26, fugee ohu  wrote:
>>>>>
>>>>>> On one of my sites (in production) if I navigate to 
>>>>>> https:///set_locale/ko
>>>>>> the browser doesn't load the page but if I'm on the site and I click the
>>>>>> link for that url it works fine I was notified about the error by GSC
>>>>>>
>>>>>
>>>>> You haven't told us what you see in the rails log when you do that.  I
>>>>> am sure you will have looked there before asking.
>>>>> Not that you have actually asked a question, just told us that you
>>>>> have this interesting occurrence.
>>>>> Also you haven't told us what is shown in the browser console when it
>>>>> happens.
>>>>>
>>>>> Colin
>>>>>
>>>>>
>>>>
>>>> Both browser console and log say 500 internal server error
>>>>
>>>
>>> Well that is why it doesn't show the page then.
>>>
>>> Colin
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Ruby on Rails: Talk" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to rubyonra...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsU1QbNV6i6XQGqbOmAauz-Q9o5wXwx1831%3D1dv4yEcaw%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsU1QbNV6i6XQGqbOmAauz-Q9o5wXwx1831%3D1dv4yEcaw%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>>
>>
>
>   <%= link_to "한국어",
> set_locale_path(locale: "ko") %>
>
>
>   get 'set_locale/:locale' => 'world#set_locale', as: 'set_locale'
>
>
>def set_locale
> I18n.locale = params[:locale] || "zh-TW"
> respond_to do |format|
> format.html { redirect_to request.referrer }
> end
>   end
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/401e2df8-b4dd-42fb-9721-39491be9bed3%40googlegroups.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/401e2df8-b4dd-42fb-9721-39491be9bed3%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
You received this message because you are subscribed 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/CAPS3bcCG5J5G6wy9KkOz1HVKsh%3D6qNtn7WsM4%3DP5PKgkhbYUjA%40mail.gmail.com.


Re: [Rails] error using direct path url vs ok when navigating by mouse

2019-10-18 Thread Ariel Juodziukynas
Sorry, `redirect_back fallback_location: root_path`.

El vie., 18 oct. 2019 a las 23:08, Ariel Juodziukynas ()
escribió:

> You are using `redirect_to request.referrer` and referrer is nil if you
> enter the url by hand.
>
> Use `redirect_back fallback: root_path` instead.
>
> El vie., 18 oct. 2019 a las 22:33, fugee ohu ()
> escribió:
>
>>
>>
>> On Friday, October 18, 2019 at 9:22:09 PM UTC-4, Ariel Juodziukynas wrote:
>>>
>>> Is the link doing a GET request or a POST request? make sure your route
>>> matches GET requests too.
>>>
>>> El vie., 18 oct. 2019 a las 18:07, Colin Law ()
>>> escribió:
>>>
>>>> On Fri, 18 Oct 2019 at 19:33, fugee ohu  wrote:
>>>>
>>>>>
>>>>>
>>>>> On Friday, October 18, 2019 at 5:57:55 AM UTC-4, Colin Law wrote:
>>>>>>
>>>>>> On Fri, 18 Oct 2019 at 09:26, fugee ohu  wrote:
>>>>>>
>>>>>>> On one of my sites (in production) if I navigate to 
>>>>>>> https:///set_locale/ko
>>>>>>> the browser doesn't load the page but if I'm on the site and I click the
>>>>>>> link for that url it works fine I was notified about the error by GSC
>>>>>>>
>>>>>>
>>>>>> You haven't told us what you see in the rails log when you do that.
>>>>>> I am sure you will have looked there before asking.
>>>>>> Not that you have actually asked a question, just told us that you
>>>>>> have this interesting occurrence.
>>>>>> Also you haven't told us what is shown in the browser console when it
>>>>>> happens.
>>>>>>
>>>>>> Colin
>>>>>>
>>>>>>
>>>>>
>>>>> Both browser console and log say 500 internal server error
>>>>>
>>>>
>>>> Well that is why it doesn't show the page then.
>>>>
>>>> Colin
>>>>
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Ruby on Rails: Talk" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to rubyonra...@googlegroups.com.
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsU1QbNV6i6XQGqbOmAauz-Q9o5wXwx1831%3D1dv4yEcaw%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsU1QbNV6i6XQGqbOmAauz-Q9o5wXwx1831%3D1dv4yEcaw%40mail.gmail.com?utm_medium=email_source=footer>
>>>> .
>>>>
>>>
>>
>>   <%= link_to "한국어",
>> set_locale_path(locale: "ko") %>
>>
>>
>>   get 'set_locale/:locale' => 'world#set_locale', as: 'set_locale'
>>
>>
>>def set_locale
>> I18n.locale = params[:locale] || "zh-TW"
>> respond_to do |format|
>> format.html { redirect_to request.referrer }
>> end
>>   end
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ruby on Rails: Talk" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to rubyonrails-talk+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/rubyonrails-talk/401e2df8-b4dd-42fb-9721-39491be9bed3%40googlegroups.com
>> <https://groups.google.com/d/msgid/rubyonrails-talk/401e2df8-b4dd-42fb-9721-39491be9bed3%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed 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/CAPS3bcCmb4ew_1LP2GzBUKpJ%2Bm%2BOL69JaDvoZQw1xSNMp%3DCSqw%40mail.gmail.com.


Re: [Rails] error using direct path url vs ok when navigating by mouse

2019-10-18 Thread Ariel Juodziukynas
Is the link doing a GET request or a POST request? make sure your route
matches GET requests too.

El vie., 18 oct. 2019 a las 18:07, Colin Law () escribió:

> On Fri, 18 Oct 2019 at 19:33, fugee ohu  wrote:
>
>>
>>
>> On Friday, October 18, 2019 at 5:57:55 AM UTC-4, Colin Law wrote:
>>>
>>> On Fri, 18 Oct 2019 at 09:26, fugee ohu  wrote:
>>>
 On one of my sites (in production) if I navigate to 
 https:///set_locale/ko
 the browser doesn't load the page but if I'm on the site and I click the
 link for that url it works fine I was notified about the error by GSC

>>>
>>> You haven't told us what you see in the rails log when you do that.  I
>>> am sure you will have looked there before asking.
>>> Not that you have actually asked a question, just told us that you have
>>> this interesting occurrence.
>>> Also you haven't told us what is shown in the browser console when it
>>> happens.
>>>
>>> Colin
>>>
>>>
>>
>> Both browser console and log say 500 internal server error
>>
>
> Well that is why it doesn't show the page then.
>
> Colin
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsU1QbNV6i6XQGqbOmAauz-Q9o5wXwx1831%3D1dv4yEcaw%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/CAPS3bcAcOgsjyEdG%2BKw-nP_p3WUvmBukM9MBSOvrOuNCTZ8Q1A%40mail.gmail.com.


Re: [Rails] Internationalization of stylesheets

2019-10-15 Thread Ariel Juodziukynas
Do the style for each locale differ a lot?

Personally, I would use a class or attribute to se the language on the body
or the html element and put all languages on the same file and add the
language as the selector for the things that should be different. It the
difference is little you shouldn't have any problem with the size since
minification and gzip compression should be enough.

If the styles are too different, I'm not sure.

El mar., 15 oct. 2019 a las 18:25, Norm Scherer ()
escribió:

> My application supports a dozen locales.  I use different stylesheets for
> each locale because things differ and it looks better if the styles fit the
> locale.
> Currently I use <%= stylesheet_link_tag "/stylesheets/#{I18n.locale}.css",
> :media => "screen" %> in my layouts as needed.
> This works but I do not get the advantages of fingerprinting and
> minification that one would get with assets.
>
> Is there a better way to do this?
>
> Thanks
> Norm
>
> --
> You received this message because you are subscribed 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/24f69bd7-9e1f-785c-90e3-46f3c3eb56b4%40earthlink.net
> 
> .
>

-- 
You received this message because you are subscribed 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/CAPS3bcDOh%3Dt%3D-p%3DPZ1hUZ%2BXtvFHjTWKUGt1wQLNrBxYw8K_%3DmQ%40mail.gmail.com.


Re: [Rails] Mysql2::Error: Access denied for user username'@'localhost' (using password: NO)

2019-10-15 Thread Ariel Juodziukynas
>From your other question, you changed mysql to sqlite, somewhere you still
have mysql configured. Look for any mysql reference on your code and remove
that.

El mar., 15 oct. 2019 a las 13:15, fugee ohu ()
escribió:

>
>
> On Tuesday, October 15, 2019 at 12:11:21 PM UTC-4, Ariel Juodziukynas
> wrote:
>>
>> I guess it's the same reason for any rails version, bad database
>> configuration. Double check your config/database.yml
>>
>> El mar., 15 oct. 2019 a las 13:04, fugee ohu ()
>> escribió:
>>
>>> Is there any reason this would happen in rails 6?
>>>
>>> --
>>> You received this message because you are subscribed 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/577f8df2-2547-491b-b552-6d5d560db95b%40googlegroups.com
>>> <https://groups.google.com/d/msgid/rubyonrails-talk/577f8df2-2547-491b-b552-6d5d560db95b%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>>
> Tried that I copied from a working database.yml
>
> --
> You received this message because you are subscribed 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/cf905986-2810-4f82-9b37-846093971a52%40googlegroups.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/cf905986-2810-4f82-9b37-846093971a52%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
You received this message because you are subscribed 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/CAPS3bcDpcStZy1u%3D58O7aZvT6Y9opSZdVy5vTDETtwbUPi%2BnGw%40mail.gmail.com.


Re: [Rails] Mysql2::Error: Access denied for user username'@'localhost' (using password: NO)

2019-10-15 Thread Ariel Juodziukynas
I guess it's the same reason for any rails version, bad database
configuration. Double check your config/database.yml

El mar., 15 oct. 2019 a las 13:04, fugee ohu ()
escribió:

> Is there any reason this would happen in rails 6?
>
> --
> You received this message because you are subscribed 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/577f8df2-2547-491b-b552-6d5d560db95b%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/CAPS3bcCJoDhReKATQ%2BXu84dySMwt%3DM0LZJcWhGGpQGvtfd_7QQ%40mail.gmail.com.


Re: [Rails] jquery function to prevent input from blank field with keypress of

2019-10-15 Thread Ariel Juodziukynas
Do you see any error on the browser's console? first thing I notice
just simple looking at it is it's missing all the ; at the end of the
lines, maybe you have a syntax error on the browser's dev tools

El mar., 15 oct. 2019 a las 11:35, fugee ohu ()
escribió:

>
> var submit_messages;
>
> $(document).on('turbolinks:load', function () {
> submit_messages()
> })
>
> submit_messages = function () {
> $('#message_content').on('keyDown', function (event) {
> if (event.keyCode === 13) {
> $('input').click()
> event.target.value = ''
> event.preventDefault()
> console.log('yes we hit enter!')
> }
>
> })
>
> }
>
> I got this from a youtube video titled Rails 6 - Real Time Chat App What
> doesn't make sense to me is why do we only clear the field if the enter key
> is pressed, why doesn't that work anyway (it doesn't clear the field) and
> why doesn't it log to console 'yes we hit enter!'
>
> --
> You received this message because you are subscribed 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/5c7f7223-915d-4960-89ad-5f3bd030568b%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/CAPS3bcAh0xpy848Ctr3SwEYCiv38%3DhYg1Y18_twseNmaK89Rfw%40mail.gmail.com.


Re: [Rails] upgrade to rails 6

2019-10-14 Thread Ariel Juodziukynas
You are mixing webpack with yarn. The only use of yarn is to download
javascript packages from https://yarnpkg.com/lang/en/ to your app's
node_modules folder. Webpacker is a gem that uses Webpack which is an
assets manager/packer solution similar (but with conceptually
different approach) to Sprockets (known as the rails' assets pipeline).
Both Webpack and Sprockets can use the node_modules folder to find the
required files.

You can use webpacker or sprockets on rails projects, you can even use both
at the same time, the only difference between rails 5 and 6 is that 5
defaults to sprockets and 6 defaults to webpacker *for new projects*. You
don't *have* to migrate to webpack if you don't want to, you should be able
to upgrade to rails 6 without using webpack and everything should work as
before.

Yarn won't create the /packs folder, webpacker should do that, maybe you
didn't configure webpacker correctly or you didn't run the webpacker
compiler. I suggest you follow the official webpacker guide to understand
it https://github.com/rails/webpacker#installation

El lun., 14 oct. 2019 a las 20:17, fugee ohu ()
escribió:

>
>
> On Monday, October 14, 2019 at 6:50:53 PM UTC-4, Ariel Juodziukynas wrote:
>>
>> You shouldn't need to do that, you could use yarn to manage JavaScript
>> dependencies with rails 5 too. Also the assets pipeline still works the
>> same way with rails 6, only webpacker is the default now, but you can keep
>> the old behaviour
>>
>> El lun., 14 oct. 2019 19:44, fugee ohu  escribió:
>>
>>> to upgrade an app to rails 6 i should run `yarn add ' for
>>> everything that was listing as "//= require " ?
>>>
>>> --
>>> You received this message because you are subscribed 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/c28d3d35-5c90-4228-bdb6-236268bf5f09%40googlegroups.com
>>> <https://groups.google.com/d/msgid/rubyonrails-talk/c28d3d35-5c90-4228-bdb6-236268bf5f09%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>>
> When I run yarn install it doesn't create a /public/packs folder and
> that's the cause of my
> Webpacker::Manifest::MissingEntryError error? Because the manifest file
> isn't found?
>
> --
> You received this message because you are subscribed 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/da0ad727-e0d7-4796-ba49-2c5fbe4a68c6%40googlegroups.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/da0ad727-e0d7-4796-ba49-2c5fbe4a68c6%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
You received this message because you are subscribed 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/CAPS3bcAc%2B7p8VBrh7P6j0FbNptWCkXXgWbhR%2BERKrm-31VFmaw%40mail.gmail.com.


Re: [Rails] upgrade to rails 6

2019-10-14 Thread Ariel Juodziukynas
You shouldn't need to do that, you could use yarn to manage JavaScript
dependencies with rails 5 too. Also the assets pipeline still works the
same way with rails 6, only webpacker is the default now, but you can keep
the old behaviour

El lun., 14 oct. 2019 19:44, fugee ohu  escribió:

> to upgrade an app to rails 6 i should run `yarn add ' for
> everything that was listing as "//= require " ?
>
> --
> You received this message because you are subscribed 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/c28d3d35-5c90-4228-bdb6-236268bf5f09%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/CAPS3bcCn_sQgiNia-Xi0eZgGS16Es3t94rBzAkFQaJb20X%2BXPw%40mail.gmail.com.


Re: [Rails] how do i add rows to the associations table in a has_many_through relation

2019-10-05 Thread Ariel Juodziukynas
I think you can actually do @physician.patients << @patient on some cases
where your join model does not require anything else, but in that case it's
more common to use a has_and_belongs_to_many association instead, if you
use a has_many :through you usually want more data on the join model so you
need to use the code on the previous response

El dom., 6 oct. 2019 a las 0:33, Ariel Juodziukynas ()
escribió:

> Following the example models from the guide
> https://guides.rubyonrails.org/association_basics.html#the-has-many-through-association
> you would do something like:
>
> @physician.appointments.create(patient: @patient)
>
>
> El sáb., 5 oct. 2019 a las 19:19, fugee ohu ()
> escribió:
>
>> how do i add rows to the associations table in a has_many_through relation
>>
>> --
>> You received this message because you are subscribed 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/47cab85e-cb43-483b-b16b-453880c44ca0%40googlegroups.com
>> <https://groups.google.com/d/msgid/rubyonrails-talk/47cab85e-cb43-483b-b16b-453880c44ca0%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed 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/CAPS3bcBhtqd5RjneK0bgD3vktJObNh24LR1r9Uh3FS2H0obRHQ%40mail.gmail.com.


Re: [Rails] how do i add rows to the associations table in a has_many_through relation

2019-10-05 Thread Ariel Juodziukynas
Following the example models from the guide
https://guides.rubyonrails.org/association_basics.html#the-has-many-through-association
you would do something like:

@physician.appointments.create(patient: @patient)


El sáb., 5 oct. 2019 a las 19:19, fugee ohu () escribió:

> how do i add rows to the associations table in a has_many_through relation
>
> --
> You received this message because you are subscribed 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/47cab85e-cb43-483b-b16b-453880c44ca0%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/CAPS3bcCwzk_qhxwXoFx6UzsYVDGqjo4abZCmiWi2qhESkqOMug%40mail.gmail.com.


Re: [Rails] Re: get request to new action using form instead of link causes param is missing or the value is empty error

2019-10-04 Thread Ariel Juodziukynas
https://apidock.com/ruby/Hash/fetch

fetch tries to get the value from a hash given a key, the second parameter
is a fallback in case the key does not exist on the hash (params), in your
case, if params[:item] does not exist, it returns {} so the next .fetch
won't fail. now the second .fetch tries to get the value for the key
:item_type, if it does not exist y returns "false". fetch is used when you
have optional keys on a hash and you need a fallback in case the key is not
present

El vie., 4 oct. 2019 a las 9:14, fugee ohu () escribió:

>
>
> On Friday, October 4, 2019 at 6:32:20 AM UTC-4, Avdhesh Sharma (ROR) wrote:
>>
>> Because in form_tag we don't define scope so all parameters comes in
>> params directry.
>> so you need to fix *item_params* method
>> *params.permit(:item_type)* to permit parameters
>>
>> your's item_params method is written to permit this params structure
>> {item: {item_type: q}
>>
>> On Friday, October 4, 2019 at 1:13:11 PM UTC+5:30, fugee ohu wrote:
>>>
>>> <%= form_tag new_item_path, :method => :get do %>
>>>
>>>   
>>> <%= select_tag(:item_type, options_for_select(Item::ITEM_TYPES))
>>> %>
>>>   
>>>
>>> 
>>> <%= submit_tag "New item" %>
>>> 
>>>
>>> ActionController::ParameterMissing in ItemsController#new param is
>>> missing or the value is empty: item
>>>
>>> In my controller I have the usual filter
>>> def item_params
>>>   params.require(:item).permit(:item_type, :title,  :item_id,
>>> item_ids: [])
>>> end
>>> ...
>>> Started GET
>>> "/items/new?item_type=General=New+item=%E2%9C%93" for 127.0.0.1
>>> at 2019-10-04 03:32:18 -0400
>>> Processing by ItemsController#new as HTML
>>>   Parameters: {"item_type"=>"General", "commit"=>"New item", "utf8"=>"✓"}
>>> Completed 400 Bad Request in 2ms (ActiveRecord: 0.0ms)
>>>
>>>
>>>
>>> ActionController::ParameterMissing (param is missing or the value is
>>> empty: item):
>>>
>>> app/controllers/items_controller.rb:109:in `item_params'
>>> app/controllers/items_controller.rb:23:in `new'
>>>  ...
>>>
>>
> What does this do?
>   if params.fetch(:item, {}).fetch(:item_type, false)
>
> --
> You received this message because you are subscribed 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/52be0f6e-0e44-4a9a-aefb-38a3eb7a555d%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/CAPS3bcBhOd0eJUuUThPCfvYDgb3o%3Dxz48k090LMyRZLxsprTXg%40mail.gmail.com.


Re: [Rails] How do I Include an array from model in views

2019-10-03 Thread Ariel Juodziukynas
SomeClass::ITEM_TYPES

El jue., 3 oct. 2019 a las 19:25, fugee ohu () escribió:

>  ITEM_TYPES =  ['General', 'Book', 'Record', 'Magazine', 'Pez dispenser',
> 'CD', 'VHS casette']
> Now I wanna use ITEM_TYPES in my view but rails says
> undefined method `ITEM_TYPES' 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 rubyonrails-talk+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/91b6e184-aa15-4da4-b567-d567005c9e6d%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/CAPS3bcDnkL6vFNizeN%2BWrMw061tnrcwYYUcd3_5R092JK3LZGA%40mail.gmail.com.


Re: [Rails] Re: Deep Nesting Help

2019-09-26 Thread Ariel Juodziukynas
But what's the actual problem? you say you have some problem but you just
pasted code with no indication on where to look. Do you have a render
error? do you have the view rendering ok but when you submit it it does not
do what you want? if it does not do what you want, what's the excepted vs
the actual behaviour?

El jue., 26 sept. 2019 a las 22:24, John Sanderbeck ()
escribió:

> I agree I can clean up the build but the problem I am having is in the
> form, not the models...
>
> I need to structure the nested form and I can't seem to figure out the
> rails syntax...
>
> Just experimenting, and currently, this is the closest I have gotten to
> what I am trying to do...
>
>   <% @dd_detail.dd_detail_categories.each do |category| %>
> <%= category.title.titleize
> %>
> <%= f.fields_for :dd_detail_items do |item| %>
> <%= item.label :title %>
> <%= item.check_box :item_check %>
> <%= item.text_field :item_value %>
> <%= item.text_area :note %>
>   
>   <%= item.fields_for :dd_detail_subitems do |subitem| %>
>   <%= subitem.label :title %>
>   <%= subitem.check_box :item_check %>
>   <%= subitem.text_field :item_value %>
>   <%= subitem.text_area :note %>
> 
>   <% end %>
> <% end %>
> <%= f.fields_for :dd_detail_subcategories do |subcategory| %>
>   <%= subcategory.label :title %>
>   <%= subcategory.fields_for :dd_detail_items do |item| %>
>   <%= item.label :title %>
>   <%= item.check_box :item_check %>
>   <%= item.text_field :item_value %>
>   <%= item.text_area :note %>
> 
> <%= item.fields_for :dd_detail_subitems do |subitem| %>
> <%= subitem.label :title %>
> <%= subitem.check_box :item_check %>
> <%= subitem.text_field :item_value %>
> <%= subitem.text_area :note %>
>   
> <% end %>
>   <% end %>
> <% end %>
>   <% end %>
>
>
>
>
> On Thursday, September 26, 2019 at 4:25:03 PM UTC-4, Ariel Juodziukynas
> wrote:
>>
>> I'm not sure I understand what's the problem, where exactly do you have
>> doubts?
>>
>> I'd suggest you first refactor that super ugly nested loops and ifs:
>> - remove the unnecesarry if's
>> DdCategory.all.each do |category|
>>   # If the Category is active, build it
>>   if category.is_active?
>>
>> can't you handle that is_active? with a scope?
>>
>> - the blocks for category.dd_items and subcategory.dd_items looks almost
>> the same, I think you can reuse some code there
>>
>> - move complex logic to other methods to clean that up, like:
>>
>> item.dd_subitems.each do |subitem|
>>
>> newitem.dd_detail_subitems.create!(dd_detail_item_id: newitem.id, title:
>> subitem.title, has_check: subitem.has_check, has_value: subitem.has_value,
>> has_note: subitem.has_note, item_check: subitem.item_check, item_value:
>> subitem.item_value, item_note: subitem.item_note)
>> end
>>
>> could be a method on newitem like "add_subitem_from(subitem)" that does
>> that create but you'll have less clutter to simplify your logic to
>> understand it better
>>
>>
>> El jue., 26 sept. 2019 a las 16:01, John Sanderbeck ()
>> escribió:
>>
>>>
>>> Another thing to note is I am also only doing an Edit of the data as the
>>>> records already have been created and are not allowed to be destroyed.
>>>>
>>>
>>> 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 rubyonra...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/rubyonrails-talk/56b5ef26-e7ed-45a8-b346-b39c45edca0f%40googlegroups.com
>>> <https://groups.google.com/d/msgid/rubyonrails-talk/56b5ef26-e7ed-45a8-b346-b39c45edca0f%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>> --
> You received this message because you are subscribed 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/424ef245-ea1a-410e-89ca-797bec4712f2%40googlegroups.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/424ef245-ea1a-410e-89ca-797bec4712f2%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
You received this message because you are subscribed 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/CAPS3bcDDVGfEPi9AXkdHeC3ZxhCN6ecqA4smkwKcnoJdw_pBPA%40mail.gmail.com.


Re: [Rails] auction site listings table

2019-09-26 Thread Ariel Juodziukynas
You were asking a way to store different values, I thought you wanted to
preserve the type (so you can distinguish 1 from "1" when you read the
record).

If you think strings are enough for your requirements just use a string
column, if you want to use one column to store values but preserve the
original type you have to serialize the value somehow (that's the is_a?...
when serializing and the case when casting).

Another option is to use two columns: one for the stringified value and one
for the original type so you can parse that again.

El jue., 26 sept. 2019 a las 17:57, fugee ohu ()
escribió:

>
>
> On Thursday, September 26, 2019 at 4:32:10 PM UTC-4, Ariel Juodziukynas
> wrote:
>>
>> The easiest but too big is a text columns so you can use
>> activerecord' serialization of attributes to save anything you want on a
>> text field and activerecord will handle casting.
>>
>> You could use a string column if you know your values won't be too big
>> (VARCHAR(255)) and you know what types you want to accept and handle
>> serialization yourself like:
>>
>> def value=(something)
>>   val = if value.is_a?(Integer)
>>   "integer:#{something}"
>> elsif value.is_a?(String)
>>   "string:#{something}"
>> elsif value.is_a?(Date)
>>   "date:#{something}
>> # etc...
>>   write_attribute(:value, val)
>> end
>>
>> def value
>>   type, val = read_attribute(:value).split(':')
>>   case type
>>   when "integer" then val.to_i
>>   when "string" then val
>>   when "date" then Date.parse(val)
>>   etc...
>> end
>>
>>
>> El jue., 26 sept. 2019 a las 17:17, fugee ohu ()
>> escribió:
>>
>>>
>>>
>>> On Monday, September 16, 2019 at 4:31:29 PM UTC-4, Ariel Juodziukynas
>>> wrote:
>>>>
>>>> Personally, I would do this:
>>>>
>>>> auctions table
>>>> (with the basic shared information of all auctions and an "auction
>>>> type"))
>>>>
>>>> properties table
>>>> property_name (like network, carrier, publisher, etc)
>>>> auction_type (like cellphone, book, etc)
>>>>
>>>> auctions_properties
>>>> auction_id
>>>> property_id
>>>> value
>>>>
>>>> That way you can have any number of auction types with any number of
>>>> specific properties with just 3 tables.
>>>>
>>>> Note that the "value" column would be some string variation (VARCHAR,
>>>> CHAR, TEXT, etc) depending on your needs, maybe you want to redesign it a
>>>> little if you want to store different types. Like if you want to store an
>>>> integer (and retrieve an integer) you'll have to save the original type and
>>>> reparse it (you could use serialization but that requires a TEXT column and
>>>> maybe you can't use that many space)
>>>>
>>>> El lun., 16 sept. 2019 a las 17:19, fugee ohu ()
>>>> escribió:
>>>>
>>>>> I was looking at some auction projects that use a single listings
>>>>> table for all auctions but I know on auction sites the form will be
>>>>> different for different types of items like if you're selling a cell phone
>>>>> there'll be a form field for network, carrier, whatever and if you're
>>>>> selling a book there'll be form fields for publisher, year of publication,
>>>>> so they would have separate tables I assume for books, cell phones, etc?
>>>>> Then how would they treat them all as one?
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed 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/512f8b73-e3a4-4e74-95e7-4281e7b54821%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/rubyonrails-talk/512f8b73-e3a4-4e74-95e7-4281e7b54821%40googlegroups.com?utm_medium=email_source=footer>
>>>>> .
>>>>>
>>>>
>>> What data type do you suggest for value column
>>>
>>> --
>>> You received this mes

Re: [Rails] auction site listings table

2019-09-26 Thread Ariel Juodziukynas
The easiest but too big is a text columns so you can use
activerecord' serialization of attributes to save anything you want on a
text field and activerecord will handle casting.

You could use a string column if you know your values won't be too big
(VARCHAR(255)) and you know what types you want to accept and handle
serialization yourself like:

def value=(something)
  val = if value.is_a?(Integer)
  "integer:#{something}"
elsif value.is_a?(String)
  "string:#{something}"
elsif value.is_a?(Date)
  "date:#{something}
# etc...
  write_attribute(:value, val)
end

def value
  type, val = read_attribute(:value).split(':')
  case type
  when "integer" then val.to_i
  when "string" then val
  when "date" then Date.parse(val)
  etc...
end


El jue., 26 sept. 2019 a las 17:17, fugee ohu ()
escribió:

>
>
> On Monday, September 16, 2019 at 4:31:29 PM UTC-4, Ariel Juodziukynas
> wrote:
>>
>> Personally, I would do this:
>>
>> auctions table
>> (with the basic shared information of all auctions and an "auction type"))
>>
>> properties table
>> property_name (like network, carrier, publisher, etc)
>> auction_type (like cellphone, book, etc)
>>
>> auctions_properties
>> auction_id
>> property_id
>> value
>>
>> That way you can have any number of auction types with any number of
>> specific properties with just 3 tables.
>>
>> Note that the "value" column would be some string variation (VARCHAR,
>> CHAR, TEXT, etc) depending on your needs, maybe you want to redesign it a
>> little if you want to store different types. Like if you want to store an
>> integer (and retrieve an integer) you'll have to save the original type and
>> reparse it (you could use serialization but that requires a TEXT column and
>> maybe you can't use that many space)
>>
>> El lun., 16 sept. 2019 a las 17:19, fugee ohu ()
>> escribió:
>>
>>> I was looking at some auction projects that use a single listings table
>>> for all auctions but I know on auction sites the form will be different for
>>> different types of items like if you're selling a cell phone there'll be a
>>> form field for network, carrier, whatever and if you're selling a book
>>> there'll be form fields for publisher, year of publication,  so they would
>>> have separate tables I assume for books, cell phones, etc? Then how would
>>> they treat them all as one?
>>>
>>> --
>>> You received this message because you are subscribed 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/512f8b73-e3a4-4e74-95e7-4281e7b54821%40googlegroups.com
>>> <https://groups.google.com/d/msgid/rubyonrails-talk/512f8b73-e3a4-4e74-95e7-4281e7b54821%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>>
> What data type do you suggest for value column
>
> --
> You received this message because you are subscribed 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/e74aaf6b-b9e1-4847-a6d3-3120829fa3bc%40googlegroups.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/e74aaf6b-b9e1-4847-a6d3-3120829fa3bc%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
You received this message because you are subscribed 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/CAPS3bcCM%3DSv-%2BExu7_dh2b7nOZhSv67e8YgHKHPqFuch6r%3D-ug%40mail.gmail.com.


Re: [Rails] Re: Deep Nesting Help

2019-09-26 Thread Ariel Juodziukynas
I'm not sure I understand what's the problem, where exactly do you have
doubts?

I'd suggest you first refactor that super ugly nested loops and ifs:
- remove the unnecesarry if's
DdCategory.all.each do |category|
  # If the Category is active, build it
  if category.is_active?

can't you handle that is_active? with a scope?

- the blocks for category.dd_items and subcategory.dd_items looks almost
the same, I think you can reuse some code there

- move complex logic to other methods to clean that up, like:

item.dd_subitems.each do |subitem|
  newitem.dd_detail_subitems.create!(dd_detail_item_id:
newitem.id, title: subitem.title, has_check: subitem.has_check, has_value:
subitem.has_value, has_note: subitem.has_note, item_check:
subitem.item_check, item_value: subitem.item_value, item_note:
subitem.item_note)
end

could be a method on newitem like "add_subitem_from(subitem)" that does
that create but you'll have less clutter to simplify your logic to
understand it better


El jue., 26 sept. 2019 a las 16:01, John Sanderbeck ()
escribió:

>
> Another thing to note is I am also only doing an Edit of the data as the
>> records already have been created and are not allowed to be destroyed.
>>
>
> 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/56b5ef26-e7ed-45a8-b346-b39c45edca0f%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/CAPS3bcDL%2Bu4RcvNAEOdAV0q44dnD6OFOJ2BXT%2BoFxhKiyPOuBw%40mail.gmail.com.


Re: [Rails] auction site listings table

2019-09-24 Thread Ariel Juodziukynas
Another option (if your database accepts it, like postgres or newer MySQL
versions) is to use a column with JSON or JSONB type. You could have a json
object with all property/value pairs. I'm not sure about performance,
indexing, etc on JSON columns though.

I'm not sure what are the categories you are talking about now, you mean
the "auction type"?

You'll have to have many many millions of auctions in order to make the
auction_properties tables too large (if your ID is an int, you have 2,000
MILLION ids to use, if you use bigint I don't even know that number, you'll
need really good indexes though haha), and even if you ever get near some
critical situation you could split table by auction type or something like
that. I doubt it's something you have to worry about right now, you'll have
a lot of more important things to improve before reaching that.

El mar., 24 sept. 2019 a las 19:19, fugee ohu ()
escribió:

>
>
> On Tuesday, September 24, 2019 at 12:37:37 AM UTC-4, hasan...@gmail.com
> wrote:
>>
>> [response inline]
>>
>> On Mon, 23 Sep 2019 at 21:32, fugee ohu  wrote:
>>
>>> But then a single item will contain many records, one for each property,
>>> wouldn't that create too-large-tables?
>>>
>>
>> By the time that becomes a problem, you'll have bigger things to worry
>> about it, mate. -- H
>>
>> --
>> OpenPGP:
>> https://sks-keyservers.net/pks/lookup?op=get=0xFEBAD7FFD041BBA1
>> If you wish to request my time, please do so using 
>> *bit.ly/hd1AppointmentRequest
>> *.
>> Si vous voudrais faire connnaisance, allez a *bit.ly/hd1AppointmentRequest
>> *.
>>
>> Sent
>> from my mobile device
>> Envoye de mon portable
>>
>
>  I can't make up my mind First, there's countless types of items Next they
> may use the category in deciding which form to load We haven't take
> categories into account  yet in this discussion
>
> --
> You received this message because you are subscribed 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/63f7e9f5-eb9a-4618-8ed9-d1f78f3a05b8%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/CAPS3bcDahpvTP45hFT6Gi58iaWL2TTXJGxYsqJeWvojQy%2B31%2BQ%40mail.gmail.com.


Re: [Rails] auction site listings table

2019-09-16 Thread Ariel Juodziukynas
Personally, I would do this:

auctions table
(with the basic shared information of all auctions and an "auction type"))

properties table
property_name (like network, carrier, publisher, etc)
auction_type (like cellphone, book, etc)

auctions_properties
auction_id
property_id
value

That way you can have any number of auction types with any number of
specific properties with just 3 tables.

Note that the "value" column would be some string variation (VARCHAR, CHAR,
TEXT, etc) depending on your needs, maybe you want to redesign it a little
if you want to store different types. Like if you want to store an integer
(and retrieve an integer) you'll have to save the original type and reparse
it (you could use serialization but that requires a TEXT column and maybe
you can't use that many space)

El lun., 16 sept. 2019 a las 17:19, fugee ohu ()
escribió:

> I was looking at some auction projects that use a single listings table
> for all auctions but I know on auction sites the form will be different for
> different types of items like if you're selling a cell phone there'll be a
> form field for network, carrier, whatever and if you're selling a book
> there'll be form fields for publisher, year of publication,  so they would
> have separate tables I assume for books, cell phones, etc? Then how would
> they treat them all as one?
>
> --
> You received this message because you are subscribed 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/512f8b73-e3a4-4e74-95e7-4281e7b54821%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/CAPS3bcA2KaAP2QthGEqOkQWLZ6T6kBnHdmh%2B0_Zp0seGeiGqeg%40mail.gmail.com.


Re: [Rails] Carrierwave multiple file uploads

2019-09-14 Thread Ariel Juodziukynas
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.


Re: [Rails] undefined method '<<' for polymorphic association

2019-09-09 Thread Ariel Juodziukynas
You can do @item.pictures << @picture

El mar., 10 sep. 2019 01:02, fugee ohu  escribió:

> class Item < ApplicationRecord
>  has_many :pictures, as: :imageable
> end
>
> class Picture < ApplicationRecord
>  belongs_to :imageable, polymorphic: true, optional: true
> end
>
> NoMethodError in PicturesController#create undefined method `<<' for
> #
>
> @item.pictures.create << @picture
>
> --
> You received this message because you are subscribed 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/1ad30bf7-4b54-49e7-86ab-8544049e567c%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/CAPS3bcBtHJWywOUZ80EVUPqa5WeQ69o6FOZ7hfQ3KrT9V_c5qQ%40mail.gmail.com.


Re: [Rails] Active Stotage - has_many attached_files ,through: Parent

2019-09-05 Thread Ariel Juodziukynas
https://github.com/rails/rails/blob/master/activestorage/lib/active_storage/attached/model.rb#L114

El jue., 5 sept. 2019 a las 10:21, Ariel Juodziukynas ()
escribió:

> `has_many_attached :files` actually sets to has_many relationships:
> `has_many :files_attachments` and `has_many :files_blobs`, you could use
> those has_many relationships to use on your user's has_many :through
> relationship.
>
> El jue., 5 sept. 2019 a las 2:57, Navid Farjad ()
> escribió:
>
>> let's say there are 2 models.
>>
>> user model:
>>
>> has_many :posts
>>
>> post model:
>>
>> belongs_to :user
>>
>> has_many_attached :files, dependent: :destroy
>>
>> what I want is simply all files of the user. something like:
>>
>> has _may :post_files , through: posts, class_name: "XXX"
>>
>> or any other way which can give me all the files of the user.
>>
>> so I want all files of all posts which belong to the user. like
>> user.post_files
>>
>> --
>> You received this message because you are subscribed 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/5fbbb4cb-4694-497b-b9b8-b80628426065%40googlegroups.com
>> <https://groups.google.com/d/msgid/rubyonrails-talk/5fbbb4cb-4694-497b-b9b8-b80628426065%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed 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/CAPS3bcDrJvfwOm5brmrvAE%2BuHN2iXWRs1-fs2X%2BmnFzU-8J%2BuA%40mail.gmail.com.


Re: [Rails] Active Stotage - has_many attached_files ,through: Parent

2019-09-05 Thread Ariel Juodziukynas
`has_many_attached :files` actually sets to has_many relationships:
`has_many :files_attachments` and `has_many :files_blobs`, you could use
those has_many relationships to use on your user's has_many :through
relationship.

El jue., 5 sept. 2019 a las 2:57, Navid Farjad ()
escribió:

> let's say there are 2 models.
>
> user model:
>
> has_many :posts
>
> post model:
>
> belongs_to :user
>
> has_many_attached :files, dependent: :destroy
>
> what I want is simply all files of the user. something like:
>
> has _may :post_files , through: posts, class_name: "XXX"
>
> or any other way which can give me all the files of the user.
>
> so I want all files of all posts which belong to the user. like
> user.post_files
>
> --
> You received this message because you are subscribed 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/5fbbb4cb-4694-497b-b9b8-b80628426065%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/CAPS3bcCLj67VZAEcfVZ7Kd0yuT-kRwJBGW3nsp769Wftr68J1A%40mail.gmail.com.


Re: [Rails] Rails 6. SyntaxError: missing ) in parenthetical (UJS)

2019-08-26 Thread Ariel Juodziukynas
Can you show the generated response of the request? try using the
escape_javascript on the second render too ("j render", the "j" at the
beginning).

El lun., 26 ago. 2019 a las 9:38, Nikola Okonesh ()
escribió:

> I use pagination ajax (kaminari and pagy gem), click more page not work.
> how it
>
>
> [image: Снимок экрана_2019-08-25_23-54-07.png]
>
>   var colum = document.querySelector("#categories_index");
>   var pagin = document.querySelector("#categories_index_paginate");
>
>   colum.innerHTML += ("<%= j render(partial: 'article/posts/post', 
> collection: @posts, cached: true) %>");
>   pagin.innerHTML = ("<%= render(partial: 'next_link') %>");
>
>
> SyntaxError: missing ) in parenthetical
>
> I not use JQuery.
>
>
> use only "@rails/ujs": "^6.0.0" webpacker.
>
>
> Rails -v 6.0.0.
> Ruby -v 2.6.1
>
>
> Help! 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/9aaa2adf-c841-4a00-a43c-92c8e4dce8f7%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/CAPS3bcDBTAdi-H1rr3Lf9hCe7C4fifz46J_ec3OYAarVJME7GQ%40mail.gmail.com.


Re: [Rails] Why are migrations called migrations?

2019-08-20 Thread Ariel Juodziukynas
The term not just for Rails, schema migration is a database concept
https://en.wikipedia.org/wiki/Schema_migration

I'm not sure about why the word "migration" is used, but maybe you get
somewhere reading database's theory or history.

El mar., 20 ago. 2019 a las 13:13, Younes Serraj ()
escribió:

> A client just asked me why we call them "database migrations" and not
> "database alterations". It made me curious, so I'm asking you guys: why?
>
> --
> You received this message because you are subscribed 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/08b7a57f-e2db-4595-9121-fffd6e139c1d%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/CAPS3bcBZSKw0d7U%2BkUqPfY1neqXePs%2BdzaKmoKNVa8aGafSu2A%40mail.gmail.com.


Re: [Rails] Rails Angular

2019-08-07 Thread Ariel Juodziukynas
You can start with the webpacker helpers
https://github.com/rails/webpacker#angular-with-typescript

El mié., 7 ago. 2019 a las 4:10, bouazza Mohamed ()
escribió:

>  Hello everyone,
>
>
> I am moving to Ruby in rails , i have an interview creating a simple app
> With Ruby on rails Angular.
>
> Do you guys have some resources for that. i will thankful for that.
>
> Best regards,
>
> Mohamed
>
> --
> You received this message because you are subscribed 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/031494c2-9842-4b20-b883-8f91c14b4532%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/CAPS3bcBe5utzemaKnKY%2BvuBfWA%2B5FOB7L8v_wPbH6x5cdBBrXA%40mail.gmail.com.


Re: [Rails] has_many & build & first_or_create

2019-07-11 Thread Ariel Juodziukynas
I don't understand what your are actually trying to do with that.

"@p" is an instance of the Project class, "find_or_crate" is a method on
active record relations, what do you expect "@p.find_or_create" to do? I
guess you can define your own instance method on Project class to do
whatever you want

what's the use of "@pt = @p.tasks.build(params)" on your example?


El jue., 11 jul. 2019 a las 16:20, tom () escribió:

> HI,
> i want to upload a has_many association. but instead of adding records, i
> would like to to incorporate first/find_or_create.
>
> is that posible?
>
> @p = Project.new(params)
> @pt = @p.tasks.build(params)
>
> @p.find_or_create 
>
> is that possible?
>
>
> 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/CADQqhMfGyFMaVpiFcgLf7GweJC7dAnr87XDwtM2UVS70LiyVNg%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/CAPS3bcDxCJQzQ%2BO8XToaSfeX%3D31Yg-0V867Ps%3DT-goTaGxs_aA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Unable to connect my ruby ​​on rails APP to a SVN repository

2019-06-28 Thread Ariel Juodziukynas
Have you tried the --verbose option when you run the command? it should
give you some information of all the steps that the command executes.

El vie., 28 jun. 2019 a las 7:15, Harold Alcalde Solarte (<
haroldalcaldesola...@gmail.com>) escribió:

> Blank space is an error when copying.
> The command works I use the same command with another repository smaller
> than this, I was thinking if it's something of the response time or the
> timeout, but I can not find anything.
>
> El jueves, 27 de junio de 2019, 15:39:41 (UTC+2), Ariel Juodziukynas
> escribió:
>>
>> You have no blank space between USER and "--password". Also add the
>> option "--verbose" to the comend to see more info of the request. Are you
>> sure the command works? I mean, I don't see how it's related to ruby nor
>> rubyonrails.
>>
>> El jue., 27 jun. 2019 a las 10:12, Harold Alcalde Solarte (<
>> haroldalca...@gmail.com>) escribió:
>>
>>> Hi all,
>>>
>>> I am trying to create in my APP a tree of directories from the data of
>>> the SVN repository. My app is on Windows and the repository I'm trying to
>>> access on another Linux server.
>>> I'm using the command to get all the files and folders:
>>>
>>> 'svn list -R http://172.xx.xx.xx/repos/Ttest/ --trust-server-cert
>>> --non-interactive --username USER--password PASSWORD'
>>>
>>> When I execute the command it doesnt do anything and once the execution
>>> is cut, the following error is shown:
>>>
>>>
>>> svn: E200015: Se atrapó una señal
>>> svn: E200015: Se atrapó una señal
>>> svn: E200015: Se atrapó una señal
>>> svn: E170013: Unable to connect to a repository at URL '
>>> http://172.xx.xx.xx/repos/Ttest/test1.txt'
>>> svn: E200015: Se atrapó una señal
>>> svn: E200015: Se atrapó una señal
>>>
>>>
>>> I have searched for those errors but I can not find a solution.
>>>
>>> Any suggestions?
>>>
>>> --
>>> You received this message because you are subscribed 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 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/c94a665a-ae09-4cea-a452-3cbc5a9eaf80%40googlegroups.com
>>> <https://groups.google.com/d/msgid/rubyonrails-talk/c94a665a-ae09-4cea-a452-3cbc5a9eaf80%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>> 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/7894c38e-f837-4659-8fac-85eaf9b21581%40googlegroups.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/7894c38e-f837-4659-8fac-85eaf9b21581%40googlegroups.com?utm_medium=email_source=footer>
> .
> 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/CAPS3bcBXM0vFQQTF3KmU1iQMD2Ne5e5MrrRtnejxyV_VpwtaMw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Unable to connect my ruby ​​on rails APP to a SVN repository

2019-06-27 Thread Ariel Juodziukynas
You have no blank space between USER and "--password". Also add the option
"--verbose" to the comend to see more info of the request. Are you sure the
command works? I mean, I don't see how it's related to ruby nor rubyonrails.

El jue., 27 jun. 2019 a las 10:12, Harold Alcalde Solarte (<
haroldalcaldesola...@gmail.com>) escribió:

> Hi all,
>
> I am trying to create in my APP a tree of directories from the data of the
> SVN repository. My app is on Windows and the repository I'm trying to
> access on another Linux server.
> I'm using the command to get all the files and folders:
>
> 'svn list -R http://172.xx.xx.xx/repos/Ttest/ --trust-server-cert 
> --non-interactive
> --username USER--password PASSWORD'
>
> When I execute the command it doesnt do anything and once the execution is
> cut, the following error is shown:
>
>
> svn: E200015: Se atrapó una señal
> svn: E200015: Se atrapó una señal
> svn: E200015: Se atrapó una señal
> svn: E170013: Unable to connect to a repository at URL '
> http://172.xx.xx.xx/repos/Ttest/test1.txt'
> svn: E200015: Se atrapó una señal
> svn: E200015: Se atrapó una señal
>
>
> I have searched for those errors but I can not find a solution.
>
> Any suggestions?
>
> --
> You received this message because you are subscribed 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/c94a665a-ae09-4cea-a452-3cbc5a9eaf80%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/CAPS3bcAmrG6FO02SHTnresA8HzT8b0y-FNJC0xZ7iDvKARp1QA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] ActionText always wraps content in

2019-06-27 Thread Ariel Juodziukynas
Just define your own partial in your app's app/view folder and it will be
used instead of that default partial.

El jue., 27 jun. 2019 a las 6:54, Ben Walsh ()
escribió:

> This behaviour is hard-coded in
> app/views/action_text/content/_layout.html.erb
>
> I think it should be possible to customize the wrapper element -- the
> current behaviour breaks backwards compatibility for us when migrating from
> TinyMCE to ActionText.
>
>
>
> --
> You received this message because you are subscribed 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/db62688d-2bbd-4be8-8697-fd0ab3df127a%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/CAPS3bcDTJMhruScGfxezisyjywV3V1Oe5VhQo89F4t4Er2Ghhw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Query Bind values with string keys

2019-06-12 Thread Ariel Juodziukynas
can you show an example of your code? you can always do "somestring" =>
"somevalue" instead of somestring: "somevalue"

El mié., 12 jun. 2019 a las 15:24, Sampson Crowley (<
sampsonsproje...@gmail.com>) escribió:

> Is it possible to use string keys for named query params? I have a very
> dynamic query builder for and Admin site, and I would like to avoid the
> extra memory use of permanently storing every key used as a symbol
>
> --
> You received this message because you are subscribed 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/15e21d12-8d43-415c-8b19-5966ee93d22a%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/CAPS3bcDPHqQLZxG6x27pNRYC4gSMvO7EQS9-W8%3Du-anoLwryTw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] @ gem cocoon - how do i

2019-06-10 Thread Ariel Juodziukynas
If you want a blank book just do @user.books.build with no attributes

El lun., 10 jun. 2019 a las 16:45, Ariel Juodziukynas ()
escribió:

> Let's say you have a user that has many books, if you want to hace some
> book prefilled just do
>
> @user.books.build(title: something, year: someyear)
>
> As long as you don't reload the relationship, the books will be on the
> user (just not persisted) and `fields_for :books` will iterate over them
>
> You can give a try to my gem for dynamic nested fields, I'd really
> appreciate it :D https://rubygems.org/gems/vanilla_nested (it's similar
> to cocoon but weight less than 10%, and it has no dependencies like cocoon
> that adds a lot of gems and depends on jquery)
>
> El lun., 10 jun. 2019 a las 16:40, tom () escribió:
>
>> HI, i am baffled on how to make the first set of nested fields visible.
>> currently, it all works, but even just in order to display the 1st set of
>> fields, i have to click "add  "
>>
>>
>> 2)
>> how do i assign values to the object in the controller to the first set ?
>>
>>
>> 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/CADQqhMe6zJLnfg_PqM9G7qijxJbiEGcetoG2uifp8tvg2rJa2w%40mail.gmail.com
>> <https://groups.google.com/d/msgid/rubyonrails-talk/CADQqhMe6zJLnfg_PqM9G7qijxJbiEGcetoG2uifp8tvg2rJa2w%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> 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/CAPS3bcDRVXqRq37-C3pR1MDcVOB5q-EZ7m_EApOHDbpYHecbXQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] @ gem cocoon - how do i

2019-06-10 Thread Ariel Juodziukynas
Let's say you have a user that has many books, if you want to hace some
book prefilled just do

@user.books.build(title: something, year: someyear)

As long as you don't reload the relationship, the books will be on the user
(just not persisted) and `fields_for :books` will iterate over them

You can give a try to my gem for dynamic nested fields, I'd really
appreciate it :D https://rubygems.org/gems/vanilla_nested (it's similar to
cocoon but weight less than 10%, and it has no dependencies like cocoon
that adds a lot of gems and depends on jquery)

El lun., 10 jun. 2019 a las 16:40, tom () escribió:

> HI, i am baffled on how to make the first set of nested fields visible.
> currently, it all works, but even just in order to display the 1st set of
> fields, i have to click "add  "
>
>
> 2)
> how do i assign values to the object in the controller to the first set ?
>
>
> 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/CADQqhMe6zJLnfg_PqM9G7qijxJbiEGcetoG2uifp8tvg2rJa2w%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/CAPS3bcAXnPUWJ8iBxONW1Yibyyb6cLc%3D0cofMBKL_83qjYN%2BDA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Rails 5.2 Custom Credentials — generally accepted way to segregate environments?

2019-06-10 Thread Ariel Juodziukynas
H I don't know if heroku lets you add custom commands during deploy,
I've only used it for tests. If it does, you could have two files on your
source credentials.yml.enc.prod and credentials.yml.enc.dev and during
deploy just rename on of them depending on the environment you are (mv
config/credentials.yml.enc config/credentials.yml.enc). It you can't add
custom command then I don't know haha.

El lun., 10 jun. 2019 a las 9:33, t...@datatravels.com (<
t...@datatravels.com>) escribió:

>
>
> On Jun 10, 2019, at 12:25 AM, Ariel Juodziukynas 
> wrote:
>
> Rails 6 will have this feature https://github.com/rails/rails/pull/33521
>
> For Rails 5.2, personally, I wouldn't add the file to the source control.
> I would do this steps:
>
> 1- run rails credentials:edit locally
> 2- add the credentials for production and save
> 3- upload the file to your hosting at /home/user/your_app/shared/config/
>
>
>
> You  mean, you don't even check-in the *encrypted* file?
>
>
> 4- configure capistrano to symlink that file on each deploy (at
> config/deploy.rb)
>
> set :linked_files, fetch(:linked_files, [])+%W{config/credentials.yml.enc}
>
> Now, on each deploy, capistrano runs a task that adds some symlink to the
> current release pointing to /shared so they are kept between releases. Your
> file /home/user/your_app/current/config/credentials.yml.enc will actually
> be a symlink to /home/user/your_app/shared/config/credentials.yml.enc. You
> can just have that on production, use one on development and add it to the
> .gitignore file so it doesn't conflict with the symlink.
>
>
>
> I think this is interesting but sort of paradigmatically different as I am
> working with 12-Factor deploys (Heroku), so there isn't a symlink paradigm
> in these cases.
>
> nonetheless, thanks for the input.
>
>
> -Jason
>
>
>
> --
> You received this message because you are subscribed 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/D070CEB0-00EF-45B2-B600-C88B3C2C8CED%40datatravels.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/D070CEB0-00EF-45B2-B600-C88B3C2C8CED%40datatravels.com?utm_medium=email_source=footer>
> .
> 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/CAPS3bcCh863N6q2WqKKovAbpUSEDdTYqc7%2BSFH0D04J5tAErzA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Rails 5.2 Custom Credentials — generally accepted way to segregate environments?

2019-06-09 Thread Ariel Juodziukynas
Rails 6 will have this feature https://github.com/rails/rails/pull/33521

For Rails 5.2, personally, I wouldn't add the file to the source control. I
would do this steps:

1- run rails credentials:edit locally
2- add the credentials for production and save
3- upload the file to your hosting at /home/user/your_app/shared/config/
4- configure capistrano to symlink that file on each deploy (at
config/deploy.rb)

set :linked_files, fetch(:linked_files, [])+%W{config/credentials.yml.enc}

Now, on each deploy, capistrano runs a task that adds some symlink to the
current release pointing to /shared so they are kept between releases. Your
file /home/user/your_app/current/config/credentials.yml.enc will actually
be a symlink to /home/user/your_app/shared/config/credentials.yml.enc. You
can just have that on production, use one on development and add it to the
.gitignore file so it doesn't conflict with the symlink.


El dom., 9 jun. 2019 a las 22:40, Jason Fleetwood-Boldt (<
t...@datatravels.com>) escribió:

> In some apps I've worked on Rails 5.1 and prior, environment variables,
> saved directly into the source code.
>
> In rails 5.2 Custom credentials encourages us to check-in only the
> encrypted version of our configuration, and keep our master.key keyfile
> outside of our repository.
>
> My question is this: Is there a way to segregate by environment? (i.e.,
> development, staging, production?)
>
> seems like the instructions for setting up AWS keys, for example, would
> have the dev, staging + production all pointing to & using the same AWS
> bucket, access key, and secret. But it seems like for many services I'd
> want to have different credentials for different environments.
>
> I found this SO post that discusses this question, but unfortunately it
> doesn't present a very good answer IMHO because the there are only two
> answers: 1) I don't quite understand and 2) a suggestion to basically check
> all your ENV variables against each of your environments, which seems like
> it could encourage a messy setup. I much like answer #1 from this SO post,
> but I don't understand how to implement it practically.
>
>
> https://stackoverflow.com/questions/53642152/how-to-manage-credentials-for-different-environments-in-rails-5-2
>
> any tip appreciated.
> Thanks,
> Jason
>
> --
> You received this message because you are subscribed 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/4577e3bb-754c-48bc-8fe3-f8fddda77481%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/CAPS3bcCWdCG2sjxthnzMwtpLpgPH26DzwkCK%3DrjQad2F3Uq9kw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


  1   2   >