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
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
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
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
> 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
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
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
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
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
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
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.
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');
}
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"},
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
34 matches
Mail list logo