Thanks Ryan, hope this type of episodes we will see more in future. While doing development we come across issues, day to day troubleshooting, issues faced, new findings, concepts which I have shared with rest of the world through http://rorguide.blogspot.com/. Hope this will be helpful to beginners too.
I don't have a ton of experience coding (although I've written working web apps w/ db backend in ASP years ago), so I'm probably missing something obvious, but I cannot for the LIFE of me figure out why I'm getting the following error:
I'm not following this tutorial exactly but rather using a combination of this and https://we.riseup.net/rails/simple-search-tutorial, which is similar in a lot of respects. The main difference seems to be that the other tutorial uses this in the form declaration:
This is because my app is set up a little bit differently. What am I missing here? I can see where the error IS (i.e. Project.search in the controller file) but I don't know how to fix it, and I've googled till I can't see straight.
Anyone know of a way to have certain cron tasks only happen on certain roles in Capistrano? Such as clearing cache files on every app server, but only running a report generator on one utility server. So far I haven't figured out a nice way to get whenever to support conditional jobs.
I implemented the code as in the example, but for me it's taking money twice: first with request_payment and then with create_recurring_profile (probably because the subscription starts today and the customer needs to pay today?)
Just a note that if you're using Heroku for hosting your production app, they recently released the Heroku Scheduler (heroku blog) which they recommend using instead of Cron. It's much easier to use but I believe only lets you get down to every 10 minutes.
Thanks to Andrew Dixon, we know that in development Website > Site URL must be http://127.0.0.1:3000 instead of http://localhost:3000. Unfortunately, Facebook seems to ignore this information, so it will still send the callback using the domain from which you activated the '/auth/facebook' route. This will produce an error if your URL is http://localhost:3000, so just use the http://127.0.0.1:3000 instead when developing.
After the user typed his information, and when you're handling the callback you just check if the authentication the user typed in exists in your database. If it doesn't, then it's a register. Is this what you meant?
If we want to run this tutorial in higher versions of rails > 3.1.
please add gem 'prototype-rails' in your Gemfile.Since prototype js has been used in this screencasts.
or try to remove this from your environment file
config.action_view.debug_rjs = true
Thank you djensen47 for pointing out the need to add
include Mongoid::MultiParameterAttributes
in model definitions when using Date or DateTime. Without it, the datetimes were being persisted as a set of discrete values (one each for day, month and year parts) and mongoid could not corece them back into a DateTime for display etc.
BTW I'm using mongoid 2.4.0 with Rails 3.1.3 and Ruby 1.9.3p0 and it did not work correctly until I made your addition. Cheers!
I would like to not have to update the password every time I modify a user. How can I leave the password field blank and just ignore the validation for the password? Does anybody know how?
This enables "vi mode", meaning vi command mode is activated when esc (or meta/option) is pressed. Comment this line out to revert to regular bash shortcuts.
Anyone else having trouble with shortcuts in zsh on Lion? eg after keying option-b (go back one word), other shortcuts like ctrl-e (go to end) no longer work. Delete and option-delete don't work at all. Terminal is configured with "Use option as meta key" checked. I tried @ErikHick's vt100 suggestion but that didn't help. I'm not using oh-my-zsh, just plain zsh with thoughtbot/laptop settings.
Hey guys, great cast. It totally works as long I don't use my authentication filter in the controller. That before_filter just checks if session[:user_id] exists (derived from "Authentication from scratch"). It redirects to an info page in the latter case that no user is signed in.
So I am using best_in_place from a signed in state but what happens is that the changes are not propagated and additionally the session seems to be reset since I am logged out then.
I am running into the same issue with rails 3.1.3. See below:
error
ruby-1.9.3-p0 :003 > User.new :username => "johnsmith"
ArgumentError: wrong number of arguments (1 for 0)
from /Volumes/Terra-Nova/jwaldrip/Sites/theirksome/config/initializers/accessible_attributes.rb:6:in `mass_assignment_authorizer'
from /Volumes/Terra-Nova/jwaldrip/.rvm/gems/ruby-1.9.3-p0/gems/activemodel-3.1.3/lib/active_model/mass_assignment_security.rb:209:in `sanitize_for_mass_assignment'
from /Volumes/Terra-Nova/jwaldrip/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/base.rb:1744:in `assign_attributes'
from /Volumes/Terra-Nova/jwaldrip/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.1.3/lib/active_record/base.rb:1567:in `initialize'
from (irb):3:in `new'
from (irb):3
from /Volumes/Terra-Nova/jwaldrip/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/commands/console.rb:45:in `start'
from /Volumes/Terra-Nova/jwaldrip/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/commands/console.rb:8:in `start'
from /Volumes/Terra-Nova/jwaldrip/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.1.3/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I like the little gems (no pun intended) you pick up watching these - like this is the second or third time I've seen you use the delegate method and I'm starting to use it...
What I mean with my last quote is the following: The idea is NOT to know how to build, for example, Active Record, but understanding better the code and the process - through a reading for example?
Great episode Ryan! I really like the introduction of Basalmiq as I've just discover this tool!
I would really LOVE to see some Ruby screencasts here (even if it's "Rails"-cast), starting with basics to metaprogramming. It could be a great, great addition associated with your "classic" rails screencasts.
I have to say my bigger problem is, even after reading few ruby books, that is still hard (for me) to understand how rails does things under the hood, and to understand WELL all parts of the framework. To be more explicit, Rails does things, but I often question myself with why? and how? (And I think most of this is because I am not enough proficient in Ruby - However, I have to say I'm starting to understand rails better through the study of another framework/language, as I started with rails/ruby)
Your episode 299: "Rails Initialization Walkthrough" was a great starting point of what I mean, and it could be awesome to see more screencasts like this in the future ;) Thanks!
I am new to Mac but I noticed that you don't need zsh to have the feature that whenever you open a new tab in the terminal, it will land in the same directory from which you make the new tab. Does anyone else also get that?
This was amazing... thanks for taking the time to explain things so clearly Ryan.
One small question: When refactoring the collection_check_box code, why do you need to pass record_id and attribute through the send method when calling them on record and object, respectively?
UPDATE:
After looking at the ruby send method documentation, is it because record_id and attribute are passed in as symbols?
Wow. Just finished it. One of your best Ryan. And this is exactly what I was looking for. I am using the Twitter Bootstrap now and I plan on wrapping all of this into a bootstrap form builder.
I've also written a zero to hero guide on my blog (it's now also returned with the help! factoid in the official rails chat room) - check it out here: Best Way to Learn Ruby & Rails
Confused about what version of Ruby to use. I thought it was suggested to use 1.9.2 for Rails 3 and 3.1, but I see you are using 1.9.3. Does it matter which is used? Is 1.9.3 better?
OSX is shipped with precompiled Ruby 1.8.7. Homebrew uses ruby files (called recipes) to execute bash statements. Though, Ruby is preinstalled on MacOS, developers prefer using RVM to manage ruby versions/gemsets.
Homebrew shouldn't need ruby. It's just a nice packaging system over macports for mac. For instance you can install mysql , libxml2, etc from homebrew. You can just go to the rvm site, run the instructions in your terminal to setup rvm. Rvm is for managing ruby versions . Install ruby through rvm . Nothing is dependent of homebrew here.
For people having problems installing it on Fedora (15/16 Live CD) and my own future reference:
note: the curl version somehow did not work on my Fedora 16 (it worked on Fedora 15 though)
which zsh => /bin/zsh
chsh -s /bin/zsh
or just chsh and choose the shell.
Logout / Restart
change .zshrc as mentioned by Ryan.
Copy rvm specific stuff from .bashrc to .zshrc
rvm --default use gemsetname (e.g 1.9.2@rails3)
Thanks Ryan, hope this type of episodes we will see more in future. While doing development we come across issues, day to day troubleshooting, issues faced, new findings, concepts which I have shared with rest of the world through http://rorguide.blogspot.com/. Hope this will be helpful to beginners too.
I don't have a ton of experience coding (although I've written working web apps w/ db backend in ASP years ago), so I'm probably missing something obvious, but I cannot for the LIFE of me figure out why I'm getting the following error:
undefined method `search' for #Class:0x4601c10
I'm not following this tutorial exactly but rather using a combination of this and https://we.riseup.net/rails/simple-search-tutorial, which is similar in a lot of respects. The main difference seems to be that the other tutorial uses this in the form declaration:
<%= form_tag :controller => 'sheets', :action => 'search', :method => 'get' do %>
This is because my app is set up a little bit differently. What am I missing here? I can see where the error IS (i.e. Project.search in the controller file) but I don't know how to fix it, and I've googled till I can't see straight.
Thanks.
Thanks for the updated routes code for Rails3 Juani, just what I was looking for!
Anyone know of a way to have certain cron tasks only happen on certain roles in Capistrano? Such as clearing cache files on every app server, but only running a report generator on one utility server. So far I haven't figured out a nice way to get whenever to support conditional jobs.
+1
does this works well along a mulit user rvm installation? will it correctly load my rails environment based on the .rvmrc file?
I implemented the code as in the example, but for me it's taking money twice: first with request_payment and then with create_recurring_profile (probably because the subscription starts today and the customer needs to pay today?)
Does anyone else have this problem?
Edit: For Facebook you will also need to give them your mobile phone number (they will offer you a link).
Just a note that if you're using Heroku for hosting your production app, they recently released the Heroku Scheduler (heroku blog) which they recommend using instead of Cron. It's much easier to use but I believe only lets you get down to every 10 minutes.
Just wanted to share with you some problems I had and how solved them when setting Twitter, Facebook and Google.
Twitter:
Facebook
Google
signed up for pro specifically for this episode. Thanks!
another +1 for a follow up on handling cancellations and insufficient funds
After the user typed his information, and when you're handling the callback you just check if the authentication the user typed in exists in your database. If it doesn't, then it's a register. Is this what you meant?
Take a look at the beginning of episode #304, Ryan explains which things have changed in Omniauth. Maybe it will help.
If we want to run this tutorial in higher versions of rails > 3.1.
please add gem 'prototype-rails' in your Gemfile.Since prototype js has been used in this screencasts.
or try to remove this from your environment file
config.action_view.debug_rjs = true
What if I want to use HAML in the presenter? I added lines to BasePresenter like so:
and used it like this in show.haml:
- presenter.show_field('Efficacy', presenter.efficacy)
and I can show that show_field is being called, but no HTML is produced. Maybe it is in the wrong context.
Hello - Excellent tutorial.
Thank you djensen47 for pointing out the need to add
include Mongoid::MultiParameterAttributes
in model definitions when using Date or DateTime. Without it, the datetimes were being persisted as a set of discrete values (one each for day, month and year parts) and mongoid could not corece them back into a DateTime for display etc.
BTW I'm using mongoid 2.4.0 with Rails 3.1.3 and Ruby 1.9.3p0 and it did not work correctly until I made your addition. Cheers!
Shouldn't this line:
klass ||= "{object.class}Presenter".constantize
be
klass ||= "#{object.class}Presenter".constantize
?
yes, and it's also definitely worth checking out Ruby Monk as well as The Ruby Game
Okay: problem was very n00bey :D I accidentally removed the csrf meta token from my layout. That caused the session reset.
I would like to not have to update the password every time I modify a user. How can I leave the password field blank and just ignore the validation for the password? Does anybody know how?
Ctrl-f, rails 3.1... and I find my savior Jakub!
I highly recommend The Intro to Rails Screencast I Wish I Had by Jeffrey Way
http://net.tutsplus.com/tutorials/ruby/the-intro-to-rails-screencast-i-wish-i-had/
Found the problem:
This enables "vi mode", meaning vi command mode is activated when esc (or meta/option) is pressed. Comment this line out to revert to regular bash shortcuts.
Anyone else having trouble with shortcuts in zsh on Lion? eg after keying option-b (go back one word), other shortcuts like ctrl-e (go to end) no longer work. Delete and option-delete don't work at all. Terminal is configured with "Use option as meta key" checked. I tried @ErikHick's vt100 suggestion but that didn't help. I'm not using oh-my-zsh, just plain zsh with thoughtbot/laptop settings.
Actually, bcrypt-ruby uses this method to parse the digest string:
The return of which is [version, cost, salt, hash]. So:
It is definitely cool!
Hey guys, great cast. It totally works as long I don't use my authentication filter in the controller. That before_filter just checks if session[:user_id] exists (derived from "Authentication from scratch"). It redirects to an info page in the latter case that no user is signed in.
So I am using best_in_place from a signed in state but what happens is that the changes are not propagated and additionally the session seems to be reset since I am logged out then.
Anyone an idea?
I am trying this example on Rails 3.1 and i get an error
< %= render @message.parent if @message.parent % >
Missing partial messages/message with {:handlers=>[:erb, :builder, :coffee], :formats=>[:html], :locale=>[:en, :en]}. Searched in:
Can someone help?
Anyone have experience setting up progressive uploads with an nginx/Unicorn setup? If so, can you post a gist of your setup?
If you use Formtastic, there's already a gem with a custom builder for bootstrap:
https://github.com/mjbellantoni/formtastic-bootstrap
I am running into the same issue with rails 3.1.3. See below:
RVM has a helpful page on integration with ZSH:
http://beginrescueend.com/integration/zsh/
It recommends not using the ZSH bundler plugin and adding __rvm_project_rvmrc to the bottom of .zshrc if using iTerm2+"Reuse Previous Tab's Directory"
I like the little gems (no pun intended) you pick up watching these - like this is the second or third time I've seen you use the delegate method and I'm starting to use it...
+1
What I mean with my last quote is the following: The idea is NOT to know how to build, for example, Active Record, but understanding better the code and the process - through a reading for example?
I wish I had had this when I was first learning Rails. I felt pretty lost, and this is exactly the information I could have used.
I didn't know about Balsamiq, I'll definitely be trying that out on my next project.
Thanks for another awesome cast!
Great episode Ryan! I really like the introduction of Basalmiq as I've just discover this tool!
I would really LOVE to see some Ruby screencasts here (even if it's "Rails"-cast), starting with basics to metaprogramming. It could be a great, great addition associated with your "classic" rails screencasts.
I have to say my bigger problem is, even after reading few ruby books, that is still hard (for me) to understand how rails does things under the hood, and to understand WELL all parts of the framework. To be more explicit, Rails does things, but I often question myself with why? and how? (And I think most of this is because I am not enough proficient in Ruby - However, I have to say I'm starting to understand rails better through the study of another framework/language, as I started with rails/ruby)
Your episode 299: "Rails Initialization Walkthrough" was a great starting point of what I mean, and it could be awesome to see more screencasts like this in the future ;) Thanks!
I am new to Mac but I noticed that you don't need zsh to have the feature that whenever you open a new tab in the terminal, it will land in the same directory from which you make the new tab. Does anyone else also get that?
Has anyone tried to do this with a has_many :through association?
For anyone who is interested, this is my form builder using the Twitter Bootstrap css framework.
https://gist.github.com/1526162
This was amazing... thanks for taking the time to explain things so clearly Ryan.
One small question: When refactoring the
collection_check_box
code, why do you need to passrecord_id
andattribute
through thesend
method when calling them onrecord
andobject
, respectively?UPDATE:
After looking at the ruby
send
method documentation, is it becauserecord_id
andattribute
are passed in as symbols?I think there is a small mistake for the Linux command to set the default Ruby version, instead of global you should use default:
rvm use 1.9.3 --default
Have you managed to get it working in production? I'm having trouble getting it working in test & it's working fine in Producton!?
No it doesn't but it's pretty easy to do without the 'acts_as_list' gem.
def sort_figures
@report = Report.find(params[:id])
params[:figures].each_with_index do |id, index|
@report.figures.find(id).update_all({position: index+1})
end
render nothing: true
end
In case anyone is wondering on how to use the custom builder by default:
ActionView::Base.default_form_builder = LabeledFormBuilder
Wow. Just finished it. One of your best Ryan. And this is exactly what I was looking for. I am using the Twitter Bootstrap now and I plan on wrapping all of this into a bootstrap form builder.
SWEET!
Great screencast Ryan!
I've also written a zero to hero guide on my blog (it's now also returned with the help! factoid in the official rails chat room) - check it out here: Best Way to Learn Ruby & Rails
Confused about what version of Ruby to use. I thought it was suggested to use 1.9.2 for Rails 3 and 3.1, but I see you are using 1.9.3. Does it matter which is used? Is 1.9.3 better?
OSX is shipped with precompiled Ruby 1.8.7. Homebrew uses ruby files (called recipes) to execute bash statements. Though, Ruby is preinstalled on MacOS, developers prefer using RVM to manage ruby versions/gemsets.
Homebrew shouldn't need ruby. It's just a nice packaging system over macports for mac. For instance you can install mysql , libxml2, etc from homebrew. You can just go to the rvm site, run the instructions in your terminal to setup rvm. Rvm is for managing ruby versions . Install ruby through rvm . Nothing is dependent of homebrew here.