Ruby on Rails Friday, July 1, 2016

> On Jul 1, 2016, at 3:20 PM, Johnny Stewart <lists@ruby-forum.com> wrote:
>
> Hi,
>
> I have 2 views on which I am running some javascript for a rating:
>
> from first view:
>
> <script>
> $(document).on('turbolinks:load', function() {
> $('.star-rating').raty({
> path: '/assets/',
> readOnly: true,
> score: function() {
> return $(this).attr('data-score');
> }
> });
> });
> </script>
>
> and second:
>
> <script>
> $(document).on('turbolinks:load', function() {
> $('#star-rating').raty({
> path: '/assets/',
> scoreName: 'review[rating]'
> });
> });
> </script>
>
> now here they work fine as is but, I don't want them in the html so I
> have moved them into reviews.coffee
>
> however, now on using browser forward and back buttons more stars are
> added every time I move back and forward with the browser(this doesn't
> happen if I leave them in the views)

You may want to modify the raty() method so that it will only initialize the object it is called on once. Set a semaphore on that object, and if it is present, fall through.

Walter

>
> I can't work out how to fix this (I also have the feeling I shouldn't be
> using turbolinks:load like this)
>
> If anyone with decent javascript knowledge could point me in the right
> direction I'd be grateful..
>
> thanks,
>
> J.
>
> --
> Posted via http://www.ruby-forum.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+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b7192a2c48791e5f8bee26b1e763742c%40ruby-forum.com.
> For more options, visit https://groups.google.com/d/optout.

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

Ruby on Rails

I don't think you need to use polymorphism for this.

I'd use STI for users and just keep the very basics in the user
table(profile name, email address, type etc). Then have something like
chef_info and athlete_info tables which contain the rest of the
differing information for each user type. This way you don't have a lot
of nil values in columns in your user table.

--
Posted via http://www.ruby-forum.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+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/81fb7e7184c77d74b1af74ca4b54c02d%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Ruby on Rails

/home/impulsief/.gem/ruby/gems/activesupport-5.0.0/lib/active_support/core_ext/object/json.rb:2:in
`require': cannot load such file -- json (LoadError)
from
/home/impulsief/.gem/ruby/gems/activesupport-5.0.0/lib/active_support/core_ext/object/json.rb:2:in
`<top (required)>'
from
/home/impulsief/.gem/ruby/gems/activesupport-5.0.0/lib/active_support/core_ext/object.rb:11:in
`require'
from
/home/impulsief/.gem/ruby/gems/activesupport-5.0.0/lib/active_support/core_ext/object.rb:11:in
`<top (required)>'
from
/home/impulsief/.gem/ruby/gems/railties-5.0.0/lib/rails/configuration.rb:2:in
`require'
from
/home/impulsief/.gem/ruby/gems/railties-5.0.0/lib/rails/configuration.rb:2:in
`<top (required)>'
from
/home/impulsief/.gem/ruby/gems/railties-5.0.0/lib/rails/railtie/configuration.rb:1:in
`require'
from
/home/impulsief/.gem/ruby/gems/railties-5.0.0/lib/rails/railtie/configuration.rb:1:in
`<top (required)>'
from
/home/impulsief/.gem/ruby/gems/railties-5.0.0/lib/rails/railtie.rb:216:in
`config'
from
/home/impulsief/.gem/ruby/gems/railties-5.0.0/lib/rails/railtie.rb:122:in
`config'
from
/home/impulsief/.gem/ruby/gems/activesupport-5.0.0/lib/active_support/i18n_railtie.rb:7:in
`<class:Railtie>'
from
/home/impulsief/.gem/ruby/gems/activesupport-5.0.0/lib/active_support/i18n_railtie.rb:6:in
`<module:I18n>'
from
/home/impulsief/.gem/ruby/gems/activesupport-5.0.0/lib/active_support/i18n_railtie.rb:5:in
`<top (required)>'
from
/home/impulsief/.gem/ruby/gems/activesupport-5.0.0/lib/active_support/railtie.rb:2:in
`require'
from
/home/impulsief/.gem/ruby/gems/activesupport-5.0.0/lib/active_support/railtie.rb:2:in
`<top (required)>'
from /home/impulsief/.gem/ruby/gems/railties-5.0.0/lib/rails.rb:14:in
`require'
from /home/impulsief/.gem/ruby/gems/railties-5.0.0/lib/rails.rb:14:in
`<top (required)>'
from
/home/impulsief/.gem/ruby/gems/railties-5.0.0/lib/rails/commands/server.rb:4:in
`require'
from
/home/impulsief/.gem/ruby/gems/railties-5.0.0/lib/rails/commands/server.rb:4:in
`<top (required)>'
from
/home/impulsief/.gem/ruby/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:138:in
`require'
from
/home/impulsief/.gem/ruby/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:138:in
`require_command!'
from
/home/impulsief/.gem/ruby/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:83:in
`server'
from
/home/impulsief/.gem/ruby/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:49:in
`run_command!'
from
/home/impulsief/.gem/ruby/gems/railties-5.0.0/lib/rails/commands.rb:18:in
`<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'


rails -v
5.0.0

ruby -v
ruby 2.2.5p319 (2016-04-26 revision 54774) [x86_64-linux]

gem -v
2.4.8

--
Posted via http://www.ruby-forum.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+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/721d36ead12f31337e46fc0fcf21baa2%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.