I already had the gem selector for guard in my Gemfile. But I got around it a different way. I just created the Guardfile before running guard init rspec:
yes, but when you want to keep the lazy loading behaviour? doing that will hit the database immediately (well, has_many association is more problematic than belongs_to) what about that?
Then you have to call @user.element_if_present('your_scope.twitter', 'twitter') instead and also have the presenter output this container markup but only once in ApplicationDecorator.
I'm having a challenge with VCR and I hope someone can help me with that.
I have a planning API I wanted to connect to and i want to validate the data from the api with my models.
In my system an Employee has an association with with an address. To get a valid employee i need to do two requests to the API.
1. To get the employee
2. To get the address of the employee.
But VCR doesn't allow me to record 2 API calls in one function. Any idea how to handle this?
I also had the issues with classify not recognizing singular names like "business", so I went with
ruby
private
deffind_commentable
commentable = nil
params.each do |name, value|
if name =~ /(.+)_id$/
commentable = name.humanize.constantize.find(value)
endend
commentable
end
I was using VCR and come into a particular problem, i do no communicate to the web service directly i first establish a reverse ssh tunnel to another computer in the network, so i could not figure a way to capture the request. Any suggestions?
Rails 3.1.1, 3.1.0: problem with routing. No route matches:
Started GET "/uhoh/" for 127.0.0.1 at 2011-10-17 16:46:27 +0400
ActionController::RoutingError (No route matches [GET] "/uhoh"):
Rendered /home/r_wilco/.rvm/gems/ruby-1.9.2-p180@rails-3.1.0/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.8ms)
there are 3 types of errors, one from the SOAP service it self, one from savon and one from the communications gem ( timeout error or no response) for the first one the web service should be able to notify of the error somehow (return a status tag) so you can handle that without the need of a begin rescue block the other cases are handled with with beging rescue.
Awesome as alway.
Ryan i will take this opportunity to motivate a topic that i think you have work with and i did have to solve when dealing with savon. The web service i comunicate with takes a couple of second to respond ( the rails app waits and does not answer to user request), so i took an approach i saw you using in episode 243, i used beanstalk and stalker, but then came the problem of updating the view instantly without the need to refresh the page when stalker/beanstalk finish.
Apparently i was the only one who didnt know how it was done but i still could not find a good example. Then in episode 281 i saw you were using faye with stalker.
I did figure out how to update the view with faye from stalker, but, could you touch this topic in a future episode? i think is a very common problem and there is not much documentation out there about how to update the view asynchronously after a background process finishes working.
Thanks Ryan..
Nice to see this as a screencast.
We once wrote a small app that consume complex types objects using Savon.
Please see https://github.com/spritle/awssoap4r
I would love to see this episode continued to include the user_activation module and how to setup a "resend activation email" feature for times when a user doesn't get the email.
Should the subscription.handleStripeResesponse function call not contain the two arguments (status and response) in the code above? The definition of the function includes these two.
I am a little late to the party, but I would recommend looking at ranked model, it handles ordering a lot nicer than the (old) acts_as_list.
Here's a snippet from the Github project page:
This libarary is written using ARel from the ground-up. This leaves the code much cleaner than many implementations. ranked-model is also optimized to write to the database as little as possible: ranks are stored as a number between -8388607 and 8388607 (the MEDIUMINT range in MySQL). When an item is given a new position, it assigns itself a rank number between two neighbors. This allows several movements of items before no digits are available between two neighbors. When this occurs, ranked-model will try to shift other records out of the way. If items can't be easily shifted anymore, it will rebalance the distribution of rank numbers across all memebers of the ranked group.
I already had the gem selector for guard in my Gemfile. But I got around it a different way. I just created the Guardfile before running
guard init rspec
:Testing of external web services would be awesome!
It's also nice for customers who prefer PayPal.
VCR is specifically designed to allow you to put as many HTTP interactions into one cassette as you want. What problem are you having?
I'd encourage you to send an email describing your issue to the mailing list, where I generally answer VCR questions.
Very helpful screencast!
I think "render nothing: true" is a typo?
is it possible to decoreate current_user ?
yes, but when you want to keep the lazy loading behaviour? doing that will hit the database immediately (well, has_many association is more problematic than belongs_to) what about that?
Maybe I would centrally put this method in ApplicationDecorator (not tested):
Then you have to call @user.element_if_present('your_scope.twitter', 'twitter') instead and also have the presenter output this container markup but only once in ApplicationDecorator.
I'm having a challenge with VCR and I hope someone can help me with that.
I have a planning API I wanted to connect to and i want to validate the data from the api with my models.
In my system an Employee has an association with with an address. To get a valid employee i need to do two requests to the API.
1. To get the employee
2. To get the address of the employee.
But VCR doesn't allow me to record 2 API calls in one function. Any idea how to handle this?
Your Github link does not work.
My features are running twice too. Is that normal? I understand that two spork environments are requires, but surely my features should only run once?
Great tutorial! How do I validate an email from a specific domain before creating the new user? I tried :
validates_presence_of :email, :if => :in_co?
validates_uniqueness_of :email, :if => :in_co?
def in_co?
email == 'test@test.com'
end
but it didn't do anything.
Thanks in advance!
Great episode!
+1 For cancellation and insufficient funds episodes.
I also had the issues with
classify
not recognizing singular names like "business", so I went withThanks Ryan!
Or
$('input[type=submit]').disable()
to get the same behavior and 'disabled' css style class added.This is a fantastic tutorial on writing degradable ajax.
Sounds like a Rails 3.1 issue with the asset pipeline and threading: https://github.com/jdpace/PDFKit/issues/110
I find myself getting the following error unless I include guard in my Gemfile too:
No such file or directory - Guardfile (Errno::ENOENT)
FWIW, using rails 3.1.1 and guard-rspec 0.5.0
Just saying incase anyone else runs into this problem too
But when you get out of it in production you'd better have a well-tested billing system :-)
Exactly and Ryan's pronunciation is ... ahem ... pas tr
SWEET!!!!!!!
Ill use it in my next project which starts tomorrow. Thanks for sharing.
I will definitively look into Ranked Model, looks really great! Thanks Jean!
Hey rbritom,
since Savon v0.9.7, the response object comes with a #doc method which returns a (memoized) Nokogiri object:
zipcode = response.doc.css("USzip").inner_text
Can i use vcr with capybara + selenium?
Awesome episode. I add capybara-mechanize for OAuth testing in my app.
Savon means soap in French in case you want to know.
I was using VCR and come into a particular problem, i do no communicate to the web service directly i first establish a reverse ssh tunnel to another computer in the network, so i could not figure a way to capture the request. Any suggestions?
Oh, one other thing, it is also posible and very easy to read the values with nokogiri using a css selector.
I find it most useful when dealing with collections
Rails 3.1.1, 3.1.0: problem with routing. No route matches:
there are 3 types of errors, one from the SOAP service it self, one from savon and one from the communications gem ( timeout error or no response) for the first one the web service should be able to notify of the error somehow (return a status tag) so you can handle that without the need of a begin rescue block the other cases are handled with with beging rescue.
Awesome as alway.
Ryan i will take this opportunity to motivate a topic that i think you have work with and i did have to solve when dealing with savon. The web service i comunicate with takes a couple of second to respond ( the rails app waits and does not answer to user request), so i took an approach i saw you using in episode 243, i used beanstalk and stalker, but then came the problem of updating the view instantly without the need to refresh the page when stalker/beanstalk finish.
Apparently i was the only one who didnt know how it was done but i still could not find a good example. Then in episode 281 i saw you were using faye with stalker.
I did figure out how to update the view with faye from stalker, but, could you touch this topic in a future episode? i think is a very common problem and there is not much documentation out there about how to update the view asynchronously after a background process finishes working.
Good cast for me.
What about errors handling raised by Savon?
Only by request.succes? ?
Regards
Sssebaaa
Thanks Ryan..
Nice to see this as a screencast.
We once wrote a small app that consume complex types objects using Savon.
Please see https://github.com/spritle/awssoap4r
We wrote a small blog as well http://www.spritle.com/blogs/2011/09/28/consume-soap-webservices-using-ruby-with-savon/
Thought this might help your followers/readers
Regards
Balaji, Spritle Software
I would love to see this episode continued to include the user_activation module and how to setup a "resend activation email" feature for times when a user doesn't get the email.
Tying to pick up some Coffeescripting from this episode:
Should the subscription.handleStripeResesponse function call not contain the two arguments (status and response) in the code above? The definition of the function includes these two.
Please explain.
Thanks.
Bharat
I love that you snuck in "When will TextMate 2 be released?"
Great episode. But "Website Payments Pro" is not available in Germany :(
Thanks man! you saved me hours of searching....
is it possible to add a 'can' ability to a whole namespace?
What about accepts_nested_attributes?
Problem with logout function and current_user value.
When calls logout, only resets session (reset_session) but not resets current_user to nil.
So when using logged_in? function after logout, it returns true because logged_in? tests current_user value.
What if instead of displaying "None Give" for missing fields you wanted to not render the field. That would mean something like
would have to become
or just
<%= @user.twitter %>
and have the presenter output the container markup, which I don't really like. Wondering if there was any cleaner way to do that? Thanks!
Any chances to subscribe Railscasts Pro via Paypal yet?
Agreed with Mischa! We need a Paypal Recurring billing II episode. =D Keep the great work Ryan!
I am a little late to the party, but I would recommend looking at ranked model, it handles ordering a lot nicer than the (old) acts_as_list.
Here's a snippet from the Github project page:
A simple Procfile for chatter-after is:
Then run with "foreman start", and the main app is at http://localhost:5000
with rails3
instead of
InstructorRegistration.where(:joins => :user, :order => 'users.last_name')
I think you want
InstructorRegistration.joins(:user).order('users.last_name').paginate
+1
I had the same question. But I think, I will have to show full list if want the users to sort through complete list.
I noticed this one before.. just want to point out that you shoud use $ as argument, not global variable