Wednesday, April 13, 2016
Notes on Redis
https://github.com/LARailsLearners/sarcastic_messages_tutorial/blob/master/redis_notes.md#cache-vs-data
Thursday, April 7, 2016
Squashing a commit
- You just sent a pull request to GitHub.
- Someone commented on it.
- You fixed the errors. You added them, commited them and pushed them again.
This actually adds another commit to that pull request and makes it really hard to read for the person who is trying to accept that commit.
What you can do to combine these commits into one, easy to read commit is to squash them together.
This is officially called squashing a commit.
https://github.com/ginatrapani/todo.txt-android/wiki/Squash-All-Commits-Related-to-a-Single-Issue-into-a-Single-Commit
Squash a commit:
$ git rebase -i HEAD~3
You'll see your commits all mashed together
pick Add to README
pick Add .gitignore
pick Edit README
and a list of options
what you want to do is Put the commit you want at the top and squash the other ones into it by removing the work pick in front of it and replacing that with the letter 's' for squash.
So it looks like this
pick Add to README
s Add .gitignore
s Edit README
save it and force push it to GitHub like this:
$ git push origin branch-name --force
Then instead of doing the whole thing again if you make another change just
git add
git commit --amend
git push origin branch-name --force
and you can add to you former commit
Monday, March 28, 2016
Group Asset deprecated in Rails 4
There is no longer any reason to declare group :asset endin your Gemfile because it was deprecated in Rails 4.
Do not use this:
gem 'whatever'
end
http://stackoverflow.com/questions/16406204/why-did-rails4-drop-support-for-assets-group-in-the-gemfile
Previously the assets group existed to avoid unintended compilation-on-demand in production. As Rails 4 doesn't behave like that anymore, it made sense to remove the asset group.
This is explained in more detail in the commit that changed that. I extracted some quotes with the actual answer.
Some gems can be needed (in production) like coffee-rails if you are using coffee templates and the fact that now assets are not precompiled on demand in production anymore.
(not precompiled on demand in production) Means that if you have that gems in production environment in 3.2.x and forget to precompile, Rails will do exactly what it does in development, precompile the assets that was requested. This is not true anymore in Rails 4, so if you don't precompile the assets using the tasks you will get a 404 when the assets are requests.
Rails 4 - Disable Turbo Links
Turbolinks is included in Rails 4. It is meant to implement fast reloading by only reloading changed to your app but I am okay with disabling Turbo links. It messes up a lot of the functionality with gems. (https://plus.google.com/+YehudaKatz/posts/A65agXRynUn)
If you need to refresh your page to see your gem them try disabling turbo links and it probably will be better.
I am trying to use the jQuery date picker. What a pain. There are some really lame, inline work arounds to disable turbo links on a per-line basis but I am just going to see what happens if I disable the entire gem.
So I decided to try the Bootstrap datepicker but then I realized that I am using Skeleton so why would I include all of Bootstrap for that one function. Plus it is no easier.
Back to jQuery UI's date picker
Turbolinks takes over any local link, sends an AJAX request for the content, and replaces the body on your current page with that content.
In your Gemfile remove:
In your application.js remove:
If you need to refresh your page to see your gem them try disabling turbo links and it probably will be better.
I am trying to use the jQuery date picker. What a pain. There are some really lame, inline work arounds to disable turbo links on a per-line basis but I am just going to see what happens if I disable the entire gem.
So I decided to try the Bootstrap datepicker but then I realized that I am using Skeleton so why would I include all of Bootstrap for that one function. Plus it is no easier.
Back to jQuery UI's date picker
http://guides.rubyonrails.org/working_with_javascript_in_rails.html#turbolinks
How Turbolinks Works
Disable Turbolinks
Turbolinks attaches a click handler to all <a> on the page. If your browser supports PushState, Turbolinks will make an Ajax request for the page, parse the response, and replace the entire <body> of the page with the <body> of the response. It will then use PushState to change the URL to the correct one, preserving refresh semantics and giving you pretty URLs.
The only thing you have to do to enable Turbolinks is have it in your Gemfile, and put //= require turbolinks in your CoffeeScript manifest, which is usually app/assets/javascripts/application.js.
If you want to disable Turbolinks for certain links, add a data-no-turbolink attribute to the tag:
<a href="..." data-no-turbolink>No turbolinks here</a>.
Turbolinks takes over any local link, sends an AJAX request for the content, and replaces the body on your current page with that content.
In your Gemfile remove:
gem 'turbolinks'
Run bundle
In your application.js remove:
//= require turbolinks
In your application.html.erb remove:
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
Delete any “data-turbolinks-track” attributes in your your other layouts.
Saturday, March 26, 2016
Heroku Reset Database
WARNING: This action will delete your database and it's contents but if that is what you want to do proceed with caution and fully warned.
To reset your database:
(The name of my database is jobby-job - change that to the name of yours.)
heroku pg:reset DATABASE_URL
Then it will ask you:
! WARNING: Destructive Action
! This command will affect the app: jobby-job
! To proceed, type "jobby-job" or re-run this command with --confirm jobby-job
> jobby-job
Resetting DATABASE_URL... done
Thursday, February 18, 2016
Fixtures - Mintest
ActiveRecord FixtureSet
rubyonrails.org/testing
funclub/test/fixtures/exercises.yml
To run the tests:
$ bin/rake test test/models/article_test.rb
rubyonrails.org/testing
funclub/test/fixtures/exercises.yml
| arms: name: windmills sets: 3 reps: 10 notes: They are fun but be careful not to go too fast and hurt your shoulders. bodypart: arms workout_id: 1 core: name: situps sets: 4 reps: 25 notes: A classic stength builder for a beach body. bodypart: Abs workout_id: 2 |
To run the tests:
$ bin/rake test test/models/article_test.rb
Wednesday, January 20, 2016
Subscribe to:
Posts (Atom)