Page 1 of 4 | Next »
[10:36:28] sunya7a: i use image_tag to refer to load an image in my view which is working in development. In production however, the image is not loaded and I get a routing error. I have precompiled my assets and I see the file in quesiton with its fingerprint in the public/assets folder. additionally when I inspect the html on the page it uses /images/image_file as source without the fingerprint. Could anyone point me to a resource that might help resolve this. I
[10:43:53] sunya7a: I just tried switching it both ways and it still won't load. My understanding is that when you precompile the assets are placed in public/assets. my stylesheets and js are loading correctly so it seems that this is correct. only images are problematic
[10:45:57] sunya7a: i suspect it has something to do with how i'm loading the image. as i said i use image_tag helper...is this not the correct use?
[10:47:14] sunya7a: I placed it in app/assets/images/brand.png and I reference it with image_tag('brand')
[10:52:05] sunya7a: tbuehlmann: i believe this is right...i wonder if it's because my image_tag is nested inside a button_tag...maybe rails is having trouble adding the fingerprint?
[10:57:02] sunya7a: tbuehlmann: that didn't work either...it still just references the simple path like this <img src="/images/brand" alt="Brand"> ... how do i tell image_tag to use the fingerprinted version?
[11:02:31] sunya7a: tbuehlmann: I found the problem...it's as simple as keeping the file extension =(
[12:22:13] sunya7a: tbuehlmann: well...to be fair...it does work in development...it just broke in production
[09:29:57] sunya7a: hi all. I'm having trouble with validating a new child record before allowing it and its parent to save. specifically, when using a custom method validator within the child model the newly created record fields are all nil and so I cannot validate any of the fields. Here's the relevant code: https://gist.github.com/sunya7a/6a14ed35cbfca5765688f940d614b33a please let me know if you want to see other parts that would help cleariify this
[09:42:37] sunya7a: dionysus69: i made a toy app to test the behavior, and as I expected, usually at that exact point the child element should have fields filled, except the id, since it is a new object and not saved yet. but in my app, everything is nil, which is confusing me
[09:43:11] sunya7a: if I let it continue though both the child and parent objects save correctly with all the information
[09:43:52] sunya7a: so it seems somehow the validator is run early? not sure why or how to delay it until the fields are filled in with the parameters coming from the form
[09:53:34] sunya7a: Andr3as: it simply creates the child object. somehow it fills in the information after the validator call
[09:53:57] sunya7a: dionysus69: i'm trying to formulate a better explanation...it's a bit complicated
[09:57:04] sunya7a: the order of events is: i submit the form and I don't see any db insertions before hitting my byebug within the validator. at this point self properties are all nil. then I continue and I see all the insertions into db and child is created including the join records
[09:58:35] sunya7a: I tried putting a byebug statement inside th econtroller and calling the update manually to see what happens...it also stops at the byebug line in the validator with self properties being nil
[10:01:43] sunya7a: dionysus69: hopefully this explains the issue: https://gist.github.com/sunya7a/b3d8377bec8b00684dcf3e3be0f6372a
[04:10:08] sunya7a: hello all. With the new form_with replacing form_for....is there an alternative fields_for as well?
[02:53:29] sunya7a: if I have a joining model with additional data in it that is required...how do i join A to B while also setting that value at the same time?
[02:55:27] sunya7a: also...can I do this on the fly while adding multiple relationships? A.relation_things << [b1, b2]
[17:12:38] sunya7a: hi, Is it possible to create a dropdown or radio button form element that allows a write in on an answer choice...sort of like a follow up field?
[20:04:31] sunya7a: When loading a particular view in my system I see a lot of messages prepended with CACHE in my logs. Is this a serious issue or is this something I can ignore? I often look for n+1 query problems and resolve them when I see them but this CACHE is something I"m not sure about
[20:18:15] sunya7a: jaegerca: okay...so safe to ignore...i think it's being called several times because I have a piece of code in the view that draws from a table to come up with a list of choices
[20:19:14] sunya7a: jaegerca: i guess i should cache the list as an instance variable in the controller instead...or would you say that seeingn CACHe multiple times has no performance issues
[18:26:21] sunya7a: What replaced sortable_element in rails 5? I can't seem to find when it was removed and what it was replaced with
[18:14:02] sunya7a: arup_r: i wanted to go to another page. I ended up solving it another way...thank you =)
[18:40:00] sunya7a: rails automatically builds an empty instance of an associated model with model.associations.build. What if I want to dispaly a list of those associations as well as a form to create more on the same page. How do I prevent it from throwing an error when iterating over model.associations and hitting the empty one?
[18:40:57] sunya7a: is this not a common use case? showing the existing ones and providing a form to add another one quickly? I feel like there should be a way to do this without adding logic in the iteration to skip over empties
[19:20:16] sunya7a: is it possible to direct a controller to load a view with a specific anchor? for example i know you can do something like edit_project_path(@project, anchor: "start-here")
[17:20:59] sunya7a: hello all. Could someone help me with the following query: https://gist.github.com/anonymous/24d3ef0be8f41d0d6aff7a7bbc951190
[17:21:20] sunya7a: I'm wondering if there's a way to combine loading the user: :profile instead of calling it twice
[15:15:48] sunya7a: I'm using foundation abide and have trouble with invalid fields that are marked for destruction. how do i tell abide to ignore these fields so that I can submit the form?
[20:08:23] sunya7a: hi all, I have a many-to-many relationship between two models A and B. In an edit form to update model A, i would like the user to type in the name of model B to associate to. How do I tell rails to check for the existence of a model B record and associating A to B before trying to create a new entry in B? I'm using accepts_nested_attributes_for and saving works...only it continues to create a new record for B
[12:05:53] sunya7a: Radar: good evening. did you have a chance to take a peek at that where query. what's your opinion on the safety of it?
[23:00:04] sunya7a: Radar: i see jquery.turbolinks in application.js .. so i don't understand why it doesn't like this one
[21:35:46] sunya7a: i have a question regarding building a where query. I would like to pass both the column name and the value. I found this http://stackoverflow.com/questions/39734301/safely-pass-a-dynamic-column-name-into-an-activerecord-query-with-a-postgres-cas
[21:35:50] sunya7a: I'm wondering if there is a better solution and if the proposed one is good and safe to use
[21:47:23] sunya7a: Radar: I'm thinking along these lines: quoted_column = self.name.constantize.connection.quote_column_name(column_name)
[21:48:58] sunya7a: I'm also sharing this method via a shared module...hence the self.name.constantize (not sure if this is good practice either)
[15:50:59] sunya7a: how do i run a js.erb view file through coffeescript engine? when i try to rename to coffee.erb my controller doesn't render it during a js request
[15:55:18] sunya7a: i am looking for what coffeebeans does I think ... is this behavior built in now or is there an updated gem...coffeebeans seems stale
[16:03:05] sunya7a: matthewd: against using coffeescript for the response? is it just preference or technical reason?
[21:49:27] sunya7a: i have a question regarding building a where query. I would like to pass both the column name and the value. I found this http://stackoverflow.com/questions/39734301/safely-pass-a-dynamic-column-name-into-an-activerecord-query-with-a-postgres-cas
[21:49:53] sunya7a: I'm wondering if there is a better solution and if the proposed one is good and safe to use
[01:43:52] sunya7a: in my migration i have t.references :user, foreign_key: true. I want user_id to be unique. I tried adding unique: true to the end of that line but it does not create a unique index, and attempting to add a unique index fails saying there's already an index on user_id
[01:45:27] sunya7a: heya radar...it's always so weird to see your good mornings so late at night (for me)
[01:53:16] sunya7a: alright...so it seems it's a name collision. Since i used t.references :user, it created user_id column as foreign key with index...only it's not unique index and putting unique: true doesn't work. when I try to add the unique index separately i get the name collision. I want to customize name with name: 'my_unique_index' ... is there a common naming convention for this? naming things is hard =/
[01:55:04] sunya7a: sevenseacat: i know...what's a common name...i don't see any of my other index named with unique...in the schema it's always a separate thing like name: "index_organizations_on_name", unique: true
[01:56:23] sunya7a: sevenseacat: unless there's a way to define unique true during table creation...i tried this and it doesn't add the uniquness: t.references :user, foreign_key: true, unique: true
[02:10:39] sunya7a: sevenseacat: ;; not liking that...i did and looking at the schema file i ended up with 2 indices defined...
[02:11:36] sunya7a: sevenseacat: one defined automatically because using references put foreign_key on user_id...and then another index on the same column for the uniqueness...i presume this is an unneccessary performance hit
[02:12:01] sunya7a: sevenseacat: better to leave uniqueness constraint in the model? what do you think
[02:13:42] sunya7a: sevenseacat: oh dropping the rails generated one is a nice idea...didn't think of that...ty
[02:20:06] sunya7a: sevenseacat: so drop fk constraint...drop index, make new one, and readd fk constraint?
[02:23:54] sunya7a: it's ok...i think it's not worth the trouble. uniquness validation in model should be good...
[02:31:35] sunya7a: sevenseacat: =( did it anyway...i guess it's how i want it now...thanks for the help!
[17:05:58] sunya7a: epochwolf: how would i do it with emoji? I'm trying to use the foundation icons...but something else would be ok...
[17:08:52] sunya7a: epochwolf: I tried entering the html code for it but it just displays the code...how would i tell the browser to convert the html code to the actual symbol?
[17:51:09] sunya7a: hi, I have a model Profile which I would like to update by calling profile.update(params). Profile belongs_to Organization and so there's profile.organization_id. I would like to overwrite when this gets set. I thought I would do this in model/profile.rb with def self.organization_id=() but it doesn't work
[19:23:07] sunya7a: cnk: hi, here are my controller and models https://gist.github.com/anonymous/796dd9fa42e8c5c7d33ec708cf400b5b
[19:25:23] sunya7a: cnk: i think it's because i'm writing it in a circular way....so on line 59 i should use something like self.update_column(:organization_id, id)?
[19:29:46] sunya7a: cnk: when i edit the user he can pick from a list of organizations. the list is loaded via ajax and updated when the user types. soemtimes there are no hits in which case the json returned puts a dummy variable with the query string embedded as <<<query>>>. I want to save that to the organizations table.
[19:31:22] sunya7a: cnk: stepping through the rails code for @profile.update(params) i see that it runs @profile.organization_id=() in attribute_assignment.rb
[19:32:30] sunya7a: cnk: i think i solved it with update_column but it's not going through any callbacks it seems now
[20:42:33] sunya7a: Is there a way to distinguish between when a has_many is being deleted because we update the dependent model and when we delete it as a result of destroying the model on which it is dependent on and we set dependent: :destroy?
[20:46:06] sunya7a: sorry...let's say I have Project has many Tags through project_tags...I want to make a distinction and run different code on project_tags when I remove a tag from a project, versus when I deleted a project and project_tags are removed as a result of Project has_many project_tags, dependent: :destroy
[19:23:13] sunya7a: what is the meaning of a method definition where the parameter is followed by a colon? for example def myMethod(param1:, param2:)
[02:15:02] sunya7a: Hi, I have a problem with how has many through associations are updating each other, in particular the entries in the join model. controller and models: https://gist.github.com/anonymous/8d4438f455978991770cc3d4edc3837d. The before_destroy callback in the degreeholdership model is never called. I suspect it's because of how #update in the controller updates the join model entries (I stepped through the activemodel code and it leads to a call to
[02:17:22] sunya7a: pupsicle: Thank you for your reply earlier. My problem is with #update seemingly not running the callbacks for associated models. Do you know of another method that would do so?
[15:54:50] sunya7a: Hi all. I'm trying to create a new object (profile) which has a many through association. When I try to save the profile i get validation errors, because the association cannot link to the profile which does not yet have an ID
[16:08:32] sunya7a: I found this which seems like this issue is automatically handled by activereocrd: http://stackoverflow.com/questions/18703036/when-will-activerecord-save-associations but it doesn't seem to be doing it in my case
[16:09:05] sunya7a: Here's code for referencee: https://gist.github.com/anonymous/796bc4b622bf54dff3be982962e3ef7b
[16:18:50] sunya7a: Andr3as: otherwise it will just run the code and not print anything to your template
[16:35:48] sunya7a: Hi again, I've found a workaround for my case, which is to set validate: false at has_many :degreeholderships. However based on http://guides.rubyonrails.org/association_basics.html#has-many-association-reference section 4.3.4 this seems unneccesary (unless I misunderstand)
[16:36:47] sunya7a: It says that if the parent object is unsaved (new_record?) then the child objects are not saved when added. all unsaved members of the association are automatically saved when parent object is saved.
[15:16:48] sunya7a: What method to update params on my model do I use if i need things such as dependent destroy to trigger?
[15:32:02] sunya7a: mustmodify: sry if i wasn't clear. I should have started with this: does model.update trigger all callbacks that are associated with my model. I read that update_all will update the fields (columns in table) without instantiating the model so callbacks aren't triggered...does #update behave the same?
[03:12:39] sunya7a: Radar: =) no worries...it was worth a shot. It does seem like my setup should be fairly common, so I think it's a simple mistake in my setup. Would you mind taking a quick look?
[03:15:49] sunya7a: Radar: thanks for the offer...I'll bang my head on it for a few more hours and will get back to you. Could you answer one thing though if you have a second. Is the expected behavior to to be able to restore entries in the join table or is it not meant to do that?
[00:09:30] sunya7a: I'm getting a UnknownPrimaryKey error when attempting to update a join table. migration and models are in here: https://gist.github.com/anonymous/5ec0962aac9c7e20a77df7ea6f460433
[00:10:25] sunya7a: earlier I was using paranoia gem and placed acts_as_paranoid on the join table. after a discussion I realized I didn't need it and removed it and changed the migration to rmeove the deleted_at column, but now I get this error. Could someone explain why?
[17:20:19] sunya7a: Hi. In my rails 5 app I'm attempting to restore a destroyed profile using recursive: true using paranoia gem. Here is my setup: https://gist.github.com/anonymous/fb677f31c4de618fa1bef2ce942af830. When restoring the profile, none of the associations are restored in the join table (which were correctly marked by active: NULL). Is there a mistake in my setup or is this a bug in the gem? I checked the issue tracker but don't see this common setup m
[17:21:14] sunya7a: matthewd: I thought about what you asked yesterday, and I believe this is the behavior I'm looking for. Only now the restore doesn't work for me. sorry for the wall of text
[18:43:51] sunya7a: I've submitted a bug report for the Paranoia gem: https://github.com/rubysherpas/paranoia/issues/394 . If anyone here could offer some insight to the issue it would be much appreciated. It might be as simple as an error in my setup or misunderstanding in how the gem works. shout out to radar who i believe is a contributor (beg)
[19:35:25] sunya7a: renegadeandy: http://api.rubyonrails.org/classes/ActionController/Redirecting.html#method-i-redirect_back
[19:48:57] sunya7a: Hi, I have the following model and controller code:https://gist.github.com/anonymous/1d90ae5cbfa1bbc76b8b4d466dc45dd8. When I update my profile and remove titles, the deleted_at is set properly on the join table. But when I re-add the title it creates a new record instead of removing the deleted_at value.
[19:49:26] sunya7a: I would also appreciate if anyone could voice opinions as to the current behavior is actually better in the long run
[20:55:46] sunya7a: matthewd: thank you. I gave it some more thought and I think I misunderstood some core concepts.
[15:13:15] sunya7a: is it preferably to use .constantize or Object.send? I would like to hear pros and cons for each if possible...unless there's an obvious choice in RoR apps?
[15:13:57] sunya7a: sevenseacat: Trying to call method on a model that i put together from a string?
[15:14:21] sunya7a: tubbo: i seee...in my case I put together a string that ends up being a model name
[15:15:08] sunya7a: i was successful using both methods....but would like to hear opinions as to which one is better in practice?
[17:29:29] sunya7a: Could someone have a look at this test on line 81 and tell me why it is failing. The error states that @wheel is nil. I don't understand why it's not seeing the instance variable that was created in the setup https://gist.github.com/anonymous/9435393b5b2e214d000c
[19:04:43] sunya7a: Could someone have a look at this test on line 81 and tell me why it is failing. The error states that @wheel is nil. I don't understand why it's not seeing the instance variable that was created in the setup https://gist.github.com/anonymous/5e3fe49c7a847540ac93
[19:13:45] sunya7a: drbrain: oh...i suppose so...although i wouldn't have thought of them as being "connected"?
[19:18:50] sunya7a: drbrain: okay...i'll keep that in mind...thanks again...hope you collect royalties on that
[19:19:39] sunya7a: drbrain: it's hard for me to do that...double check things that I know to be true....or assumed to be true
[19:20:53] sunya7a: drbrain: ahh...okay...that's what is happening...i'm not too familiar with those techniques....that is referred to as "monkey patching"?
[18:28:15] sunya7a: Could someone have a look at this test on line 81 and tell me why it is failing. The error states that @wheel is nil. I don't understand what it's not seeing the instance variable that was created in the setup https://gist.github.com/anonymous/9435393b5b2e214d000c
[03:10:04] sunya7a: Radar: i see...found http://ruby-doc.org/core-2.2.0/Module.html#method-i-public i think i understand...thank you
[15:50:06] sunya7a: how do i grab data from the session object while setting a default value in case the key doesn't exist? I tried #fetch but it seems session doesn't respond to it...I'm on RoR 3.0.20
[15:54:24] sunya7a: Papierkorb: do you know why #fetch doesn't work on session? i always thought it is a Hash
[15:57:26] sunya7a: Papierkorb: Okay...ill try to find the source code for it to see what exactly session is...thank you
[16:05:25] sunya7a: Papierkorb: ahh...turns out that it does respond to fetch...only fetch is not able to automatically convert a symbol into string...while session[:a] does. I guess that is added behavior by RoR to session