Keith

Age: 25

Aug
27
comment Should I worry about method reusing in a rails model?
I think if it's something you know you're going to use multiple places, make life easier on yourself and encapsulate this logic so you only update one area of code instead of a handful. I think you see examples of duplication of common actions because sometimes it's hard to have the foresight that certain actions will need to occur multiple places, and the programmer doesn't take the time to refactor previous code to use a new interface.
Aug
27
comment Should I worry about method reusing in a rails model?
Sure devise adds a lot of this functionality, but I think the example above was just to give an example to a more generic approach throughout the project.
Aug
26
awarded Critic
Aug
21
comment Basic git process - I coded in a wrong direction and now I want to back up
From my understanding of the question, you want master to point at feature 2's commit and continue work from there. Just to be safe since I can't see your actual repository, run git reset --hard <feature 2's commit sha-id> which will move master to that point. You can verify your new branch is created and master is moved properly by looking at gitk.
Aug
21
comment Basic git process - I coded in a wrong direction and now I want to back up
Ahh, I see. The reason I'm saying switch back to master right after is because after we create feature branch to point to the same place (to preserve commits), we want to be on master to move it back to a point before feature 3 and 4 were implemented. It would have been cleaner for me to say git branch -f <feature-branch> master as step one so I didn't have the extra step of switching back to master
Aug
20
comment Basic git process - I coded in a wrong direction and now I want to back up
You are correct that git checkout -b will create a new branch and switch to that branch in one command. I'm a little confused by "the second command would seem to do nothing". git branch -f <feature-branch> master will create the new feature branch for you, but will not switch to that branch, which is what the second command does for you. Or, you can use the shorthand git checkout -b <feature-branch> master to do it all in one.
Aug
20
answered Basic git process - I coded in a wrong direction and now I want to back up
Aug
20
answered Three forms on the same page produce error alert when just one is submitted
Aug
20
comment C - how to use extern variable
Here is a great related question describing how to use extern variables: stackoverflow.com/questions/1433204/…
Aug
19
answered Configuring vim for switching between tabs
Aug
19
revised Rails 4 How to access model attributes in instance method
added 449 characters in body
Aug
19
comment Rails 4 How to access model attributes in instance method
ahh, doing find_by_id is returning a result set, which is the ActiveRecord_Relation part. Change find_by_id to find, or change the statement to Constant.find_by_id(params[:id]).first
Aug
19
answered Rails 4 How to access model attributes in instance method
Aug
19
comment has_many through can not modify association
Can you please show your code
Aug
12
answered User signup validations are being ignored - using devise
Aug
11
comment Why is Date(N).toString() different from d= new Date(N); d.toString()
similar question: stackoverflow.com/a/9584767/1290374
Aug
11
comment How to manipulate user's form entry before submitting in Rails?
I'm not the most familiar with ransack so some of this might not work. I noticed the field in your form says address_or_city_cont. Can that be changed to address_or_city_or_zip_code_cont? If not, I would inject the search value into params on the server side like params[:search][:zip_code] = <search value>. The hash might have to be formatted different from this based on how ransack expects things.
Aug
11
answered How to manipulate user's form entry before submitting in Rails?
Jul
30
comment rails and javascript, know if the user has confirmed a dialog
From my perspective, the rails jquery-ujs is the more popular and maintained of the two and if there was an issue, this project would be more likely to get a timely fix.
Jul
30
comment rails and javascript, know if the user has confirmed a dialog
Do you want to or are restricted to using rails prototype-ujs? If not, it looks like jqueyr-ujs fires an event 'confirm:complete' which sends along the response: github.com/rails/jquery-ujs/blob/master/src/rails.js#L256
1 2 3 4