[Rails] Re: Re: Re: Re: Multiple user types. Polymorphism Devise

2016-07-14 Thread Johnny Stewart
Colin Law wrote in post #1184608: > > Possibly an even better solution to the OPs problem would be to use > roles for different user types and not even have the complexity of > STI. It depends how much role specific data and behaviour there is. > My advice would be to start with just roles and

[Rails] Re: Re: Re: Multiple user types. Polymorphism Devise

2016-07-13 Thread Johnny Stewart
Colin Law wrote in post #1184606: > On 13 July 2016 at 16:14, Johnny Stewart <li...@ruby-forum.com> wrote: >>>> So, you don't need to keep all the chef or athlete data in the user >> only has to handle registrations etc. I don't think there is any need to >> hold d

[Rails] Re: Re: Multiple user types. Polymorphism Devise

2016-07-13 Thread Johnny Stewart
Colin Law wrote in post #1184575: > On 11 July 2016 at 19:41, Johnny Stewart <li...@ruby-forum.com> wrote: >> in a table like ChefInfo >> >> then if user1 is a chef, he would have all the user info + type Chef and >> he would have an entry in the chef table &g

[Rails] Re: Re: User Points System

2016-07-13 Thread Johnny Stewart
Greg Navis wrote in post #1184584: > Yes, gems often make things more complicated than necessary. Regarding > `spent` - if I earned 10 points and want to spend 2 how would you model > this? I'm not sure whether that's possible in your app but it's a thing > to > keep in mind. Good point - I will

[Rails] Re: Multiple user types. Polymorphism Devise

2016-07-13 Thread Johnny Stewart
> Thanks for your response. > But isn't this a polymorphic association?. I'am trying to do exactly > that with a polymorphic association, that is, create the user table with > all the common information, and with meta_type:string (that saves the > type of user) and meta_id:integer (that saves the

[Rails] Re: Multiple user types. Polymorphism Devise

2016-07-11 Thread Johnny Stewart
No tutorial that I know of.. You have the same information for all user types, namely just the important information for users. So - you keep password, username, first name, last name, email address etc in the User table. Stuff like sport, training ground, weight, height, body-fat etc would go

[Rails] Re: User Points System

2016-07-10 Thread Johnny Stewart
Hi Greg, yeah - I think I have abandoned using a gem for this and will roll my own. I've had more of a look into it now and it doesn't look like as big a job as I had imagined.. I think it will be easier to put a "spent" boolean on the point model though, rather than create negative point

[Rails] Re: Won't display current_user.appointment

2016-07-07 Thread Johnny Stewart
Ruth Stephenson wrote in post #1184508: > Unfortunately, I have already tried that. When I click on the link it > does nothing. It stays on whatever page i'm on but won't do > anything.It's very strange > > Johnny Stewart wrote in post #1184507: >> Ruth Stephenson wrote in pos

[Rails] Re: Won't display current_user.appointment

2016-07-07 Thread Johnny Stewart
Ruth Stephenson wrote in post #1184504: > ERROR: > SQLite3::SQLException: no such column: appointments.appointment_date: This is telling you that there is no appointment_date column in your appointments table. replace appointment_date with whatever you have named the appointment date column in

[Rails] User Points System

2016-07-06 Thread Johnny Stewart
Hi, I am currently writing an ROR application which I am looking to add user points to. I've been looking at Merit for this, but I don't know if it is going to be right for what I am looking to get out of it. The points are the main thing, but I may use the badges and rating features in the

[Rails] Re: Multiple user types. Polymorphism Devise

2016-07-01 Thread Johnny Stewart
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.

[Rails] javascript in html file

2016-07-01 Thread Johnny Stewart
Hi, I have 2 views on which I am running some javascript for a rating: from first view: $(document).on('turbolinks:load', function() { $('.star-rating').raty({ path: '/assets/', readOnly: true, score: function() { return $(this).attr('data-score'); }

[Rails] Re: Changing primary key

2016-05-19 Thread Johnny Stewart
OK, next problem.. When I create a comment (from a form on the status page) the params hash contains a parameter called: status_entity_id What I want is just: entity_id Processing by CommentsController#create as JS Parameters: {"utf8"=>"✓", "comment"=>{"content"=>"testing123"},

[Rails] Re: Changing primary key

2016-05-19 Thread Johnny Stewart
Thanks Nanaya, looks like that will do the trick! Johnny -- 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

[Rails] Re: Changing primary key

2016-05-19 Thread Johnny Stewart
Hi Fred, @comments is a collection of comments on a status Johnny -- 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

[Rails] Re: Changing primary key

2016-05-19 Thread Johnny Stewart
Hmmm.. OK, I have put this in place: class Comment < ApplicationRecord belongs_to :user belongs_to :published_entity, foreign_key: "entity_id" but rails is still trying to use status_id.. (I have a class PublishedEntity which status inherits from) class Status < PublishedEntity

[Rails] Changing primary key

2016-05-19 Thread Johnny Stewart
I have changed the primary key on a table “statuses” to now be entity_id In my status model I have: self.primary_key = 'entity_id' when I try to render a collection of comments associated with a status like so: <%= render @comments %> I get this error: PG::UndefinedColumn: ERROR: column

[Rails] Polymorphic associations for comments or no?

2016-05-16 Thread Johnny Stewart
When looking at comments which will be made on different types (say post, picture, article) I see a lot of advice towards using polymorphic associations for this. Ryan Bates has a good railscast on it: http://railscasts.com/episodes/154-polymorphic-association-revised However, I'm not sure I see

[Rails] Re: Is there any tool available for image upload resizing / view based image style rendering?

2016-05-16 Thread Johnny Stewart
Hi there, I'd take a look at attache: https://github.com/choonkeat/attache-rails https://github.com/choonkeat/attache regards, Johnny -- 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

[Rails] Re: Dropdown choices

2016-05-08 Thread Johnny Stewart
Hi Nanaya, I saw that, but couldn't work out why the other answers made things so complicated - I thought maybe I was not getting something important that the extra model and db table allows. I hadn't considered Enum - looking into it now.. -- Posted via http://www.ruby-forum.com/. -- You

[Rails] Re: Dropdown choices

2016-05-08 Thread Johnny Stewart
Hi Ryan, yes that's about it - the choices I want to have will not be created by user input (I don't think they are in the SO example either - I think the OP only wants to allow the three choices he specified, which is why I couldn't work out why the answers seemed to overcomplicate things so

[Rails] Dropdown choices

2016-05-08 Thread Johnny Stewart
I have a model where I want a few specific choices for a dropdown to set a variable, very much like this: http://stackoverflow.com/questions/14113057/how-to... I'm trying to work out why all the answers to this question involve creating a new model and db table just for the three choices

[Rails] Dropdown choices

2016-05-08 Thread Johnny Stewart
I have a model where I want a few specific choices for a dropdown to set a variable, very much like this: http://stackoverflow.com/questions/14113057/how-to-have-a-drop-down-select-field-in-a-rails-form I'm trying to work out why all the answers to this question involve creating a new model and

[Rails] Re: Adding an "Edited at:"

2016-05-04 Thread Johnny Stewart
Thanks Colin, solid advice, I'll just use the comparison and take it from there... Johnny -- 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

[Rails] Adding an "Edited at:"

2016-05-03 Thread Johnny Stewart
I'm looking to add an edited_at field on comments etc in a Rails 5 app (only shown if it has been edited). I know I can compare created_at and updated_at to check if the comment has been edited but it seems like a hit on the db if there are a lot of comments. Should I add an edited at boolean to

[Rails] Ajax editing of comments

2016-04-28 Thread Johnny Stewart
I have a rails 5 project and have followed this tutorial to implement commenting: http://railscasts.com/episodes/154-polymorphic-association-revised Comments are listed below the instance that they are associated with, I have creating and deleting comments working with ajax, but I can't work out

[Rails] Re: Tagging pictures

2016-03-23 Thread Johnny Stewart
OK, thanks Colin, I will most likely go that route then, I dare say it will save pain later on should I want to do anything more complex with this as well, J. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on

[Rails] Re: Tagging pictures

2016-03-23 Thread Johnny Stewart
Yes - I see that, it was late, got albums and images the wrong way round there.. I've been learning for a few months now, so I've seen and completed that tutorial and a few others. Its an excellent resource especially considering its free! I'm going to do a bit of reading up on associations

[Rails] Re: Tagging pictures

2016-03-22 Thread Johnny Stewart
OK, thanks for the pointers - I'll get through a bit of reading on this tomorrow and see if I can't make enough sense of it to get something working.. Thanks again, J. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups

[Rails] Re: Tagging pictures

2016-03-22 Thread Johnny Stewart
hmmm... OK - I was thinking: User has_many Albums User has_many Images through Albums Image belongs_to User Image belongs_to Album Album has_one user Album has_many images am I overcomplicating things here? I have to say I'm not sure what the advantages/disadvantages to the setup above

[Rails] Re: Tagging pictures

2016-03-22 Thread Johnny Stewart
Interesting, do you mean this sort of thing: http://guides.rubyonrails.org/association_basics.html would you do that like- has many through? I'll take a look at that.. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups

[Rails] Re: Tagging pictures

2016-03-22 Thread Johnny Stewart
OK, I see what you mean, however, I'd like each user to have their own categories only and they would likely only have 5 - 10 max for the most part, as they would only be able to put each photo in one category so the album analogy would work. So in that sense they are not really tags like a

[Rails] Re: Tagging pictures

2016-03-22 Thread Johnny Stewart
I've nothing specifically against it, but as I say I think just adding a hash to the user model and then filtering on the entries therein seems like it would be a lot more light weight no? Is there some specific advantage I'd get by using acts_as_taggable_on? -- Posted via

[Rails] Tagging pictures

2016-03-22 Thread Johnny Stewart
I'm working on an app which has an image upload facility for users, I want users to be able to create 'albums' for their pictures. The way I'm thinking about implementing this is to have a hash in the user model for each user which they can add categories to and will then be available as a