It's a fairly basic Rails integration Gem for Mailman. It makes it easier to define your email router across your application, for instance from mailers or models. It also includes some rake tasks for daemonization which solves some of the problems mentioned in these comments.
This is awesome, but what if I want the link_to to save the form data before it is clicked?
It seems wicked defaults to the form id to edit_put (maybe its a rails default?)
I cannot seem to over write this, but no matters since page per page i just want my link to save the data there, I thought I could call a submit action:
And then the java script on the page is:
$(document).ready(function() {
$('#my-link-check').click(function(event){
var form = document.getElementById("edit_put");
if(form!=null)
form.submit();
});
});
But this seems to not submit (does if have a breakpoint in firebug, odd) and then if that submit does work it doesnt goto the next page...
our "Save Document" buttons on these pages do work, and are just
submits. So not sure what critical piece I am missing to make this work.
Curious what the MemberProfile model would look like if it were a PORO and not inheriting from AR as suggested. It could not make use of AR associations in the model, so what would that look like? Thanks for a great episode!
On the one hand, if the user can try it, and doesn't like it after all, they definitely won't convert (and will look for another solution).
On the other, if the user needs to register before they can use it, they've already gone through the hurdles and might as well use it then. Even if they like it just as much (less) as in the previous example, the fact that the user will need to go through some more hurdles to find something else might keep the user with your solution.
Of course there's a tight balance there, but it's the same thing with credit cards and trials. Intuitively you might think it's best to allow people to do a trial without entering a CC#, but in fact if you make them enter a CC# for a trial, they'll be more prone to convert, since it's automatic (path of least resistance from then on for the user - they don't need to do anythign anymore)
Did anybody actually make it work in google or firefox? As soon, has I upload the picture in firefox the items get created but the image don't upload anymore. Google doesn't even function on it
Instead of booleans (or STI), you can also use a state machine (last week pro episode ;-)) to keep track of the user's status (guest, registered user, admin...), for instance as describe in this railstips blog (this example modeli{s,z}es an inactive/active/abusive user).
No offense but, using a gem is fine but dont you think you could write it from scratch so you dont work 1 day of adding a feature to it? It will take you a couple of hours to write authentication from scratch.
Ryan, I'm a new rails dev and your screencasts are the best resource! Thanks for making them easy to get and search!
While following this screencast I was getting:
undefined method `visit' for #...
For my test. Turns out the current versions of Rspec and Capabara have moved the auto include of Capybara's DSL to only be included in the 'features' space of the spec tests.
You can either do the Capybara 'visit' (and other methods) into only the features tests or you can add Capybara's DSL to the request scope.
I chose to add the DSL to request scope so I could follow along.
in spec/spec_helper.rb
RSpec.configure do |config|
...
config.include Capybara::DSL, :type => :request
...
end
Instead of playing with booleans to change objects behaviors, what you guys think about STI?
Personally, I'd made the Guest class as a subclass of User. It's then possible to override behavior (validations, methods, etc.) without any ugly if. It sounds more OO to me. Am I right?
Hi HuffModdy,
That's pretty much what I was trying to do :), thanks for putting me back on the way :).
For those who try the same, don't forget to add some logic to give back his session to the user if he cancels the signin or sinup for any reason (he returns to the homepage, for instance).
Something like this should do the trick (before_filter in application controller)
I wrote an article on doing this but in my solution, upon registering I just updated the current anonymous user instead of creating a new one and transferring all their data.
When you modified the session new page (i.e. changing the email address for username), it is possible that you forgot to change the password_field for a text_field. This might explain what you see.
There's no problem with destroying the guest user, just call reload first.
Although you would still need the rake tasks for users who never become members.
You could store the guest_user_id as a session variable, logout the guest then direct them to a sign up form. After that, generate the devise registrations controller, and do something along the lines of:
Thanks a lot Ryan for this great episode (one more :).
I'm just fighting a bit with Devise, and after a day sweating, I'm asking for help. First, here's the way I went, it could help some other folks around:
- I duplicated Devise Validatable class to apps/models/devise/models/validatable.rb, and patched the validation function to check for guest (password_required? and email_required? + created a custom one to ignore the validates_format_of :email as I store a uuid instead of an email for my guests, a bit dirty but efficient :)
- I then patched some of my controller on actions where I want to create a guest user on the fly (ex: if you create a content) and used sign_in_and_redirect(:user, my_new_gest_user) to log the guest in after creation.
The whole thing works fine, I start as anonymous, go to add a content, my patched controller does the job and I end-up as a guest user, logged in and with a content. I can then play with my app and create other pieces of content, works fine.
BUT (there is a but :) I'm stuck with the step where I need to create a new user if the guest wants to actually sign_up. Devise will refuse any sign_in or sign_up action, which makes sense as I'm kind of knocking on a door which is already opened :). Here I must admit I'm limited by my still-partial knowledge of Rails. I have the intuition I should override Devise controller to pass it as a parameter my guest_user.id, and tell him "Be nice, store this somewhere and let me signup" so I could then post-process it with something like your move_to method... but I can't find my way through Devise.
If anybody has gone through, I'll be glad to have a few crisps of advise to follow :).
Night here in Europe, I'll sleep on my code, cheers to those still working somewhere else :).
Something to keep in mind: the /announcements/:id/hide route will fail with a 500 error if visited directly, as there is no request.referer in that case. This should be checked by the controller and redirect to a default url in that case, or maybe render a 404.
Also, I would add rel="nofollow" to the link, so that spider bots don't follow it.
I am in charge of a relatively large app, which for the better part does not use ajax loading of content, I can see turbolinks being perfect for that. As other commentators have mentioned if you have already gone down the PJAX or Ajax Content loading route it might be more hassle than its worth.
I seek advice about configuring the domain length, different for staging and production. I have an app that uses subdomain. The same app is hosted in a staging environment and production environment on the same server.
Yeah, it's great. I had to implement something similar a few years back but I managed to make it whey too complicated, Ryan's solution is much simpler!
Interesting.
Intuitively I'd say it has a big positive impact, but I confess it's only a gut feeling as I've never monitored such things.
I'd be very interested in seeing actual numbers. Is there some literature out there about this?
Thank you for the video. I must admit though, I'm not a fan of this approach - numerous experiments have proved that this approach doesn't really improve conversions.
This would brie exactly what I was looking for, I was just thinking about how to do this on another app. I think stripe does this, seems great from usability perspective
Hello! I don't have Railscasts Pro, so I havent't seen the episode, but thought you guys might find this useful:
https://github.com/johncant/mailman-rails
It's a fairly basic Rails integration Gem for Mailman. It makes it easier to define your email router across your application, for instance from mailers or models. It also includes some rake tasks for daemonization which solves some of the problems mentioned in these comments.
Excellent, now I understand this. Thanks
To this question I would also like to know the answer. Can somebody help?
Thanks - this worked for me.
sphinx works well for english, how can I configure it for arabic language. kindly reply.
Thanks in advance.
You're absolutely right, I've corrected it :)
I want to implement 236-omniauth-part-2 in my Project But i get error
NoMethodError in AuthenticationsController#create
undefined method `find_by_provider_and_uid' for Authentication:Class
I define it in stackoverflow. http://stackoverflow.com/questions/13561140/i-am-using-rails-cast-omniauth-and-i-get-this-error
awesome
Could you not just direct "become a member" to an edit form for the guest user?
This is awesome, but what if I want the link_to to save the form data before it is clicked?
It seems wicked defaults to the form id to edit_put (maybe its a rails default?)
I cannot seem to over write this, but no matters since page per page i just want my link to save the data there, I thought I could call a submit action:
And then the java script on the page is:
$(document).ready(function() {
$('#my-link-check').click(function(event){
var form = document.getElementById("edit_put");
if(form!=null)
form.submit();
});
});
But this seems to not submit (does if have a breakpoint in firebug, odd) and then if that submit does work it doesnt goto the next page...
our "Save Document" buttons on these pages do work, and are just
submits. So not sure what critical piece I am missing to make this work.
How did you guys fix this?
Hi Ryan, in the ASCIIcast "rake jobs:works" should be "rake jobs:work" ?
Thanks for this great episode!
Curious what the MemberProfile model would look like if it were a PORO and not inheriting from AR as suggested. It could not make use of AR associations in the model, so what would that look like? Thanks for a great episode!
Or even
rails g migration add_profile_to_users profile:belongs_to{polymorphic}
Any reason why you're not using
references
in the migration?instead of
Nice refactoring.
Btw. when using generate migration you can use these advanced features (https://github.com/rails/rails/blob/master/railties/test/generators/model_generator_test.rb#L116-183) to create indexes, polymorphic associations, etc from command line without editing the migrations by hand afterwards.
a wonderful framework
True but then you need to worry about every time you save the record after that. I am very careful whenever saving without validations.
Great points everyone, this is actually the topic of my next episode!
Found a very weird bug, maybe it is actually poltergeist related. While I haven't had time to fully investigate it here is what happens:
boom, after the second visit I find that that I am logged out, current_user is nil.
If, on the other hand instead of doing the second visit call I use respective click_link sequence everything works like a charm.
Koala.http_service.http_options = {
:ssl => { :ca_path => "/etc/ssl/certs" }
}
That ca_path is a path to your system wide ca_certs, in Ubuntu they are located at /usr/lib/ssl/certs.
I bet it goes something like this:
On the one hand, if the user can try it, and doesn't like it after all, they definitely won't convert (and will look for another solution).
On the other, if the user needs to register before they can use it, they've already gone through the hurdles and might as well use it then. Even if they like it just as much (less) as in the previous example, the fact that the user will need to go through some more hurdles to find something else might keep the user with your solution.
Of course there's a tight balance there, but it's the same thing with credit cards and trials. Intuitively you might think it's best to allow people to do a trial without entering a CC#, but in fact if you make them enter a CC# for a trial, they'll be more prone to convert, since it's automatic (path of least resistance from then on for the user - they don't need to do anythign anymore)
I tried install with mac port, but conf verification failed with this error,
nginx: [emerg] unknown directive "ssl" in /opt/local/etc/nginx/nginx.conf:102
Found out that should install nginx with ssl option, it is not there by default
sudo port install nginx +ssl
save(:validate => false) if current_user.guest?
Bang! :)
Did anybody actually make it work in google or firefox? As soon, has I upload the picture in firefox the items get created but the image don't upload anymore. Google doesn't even function on it
Guys, do you know how to after updating object always change state to awaiting_review? I am using workflow gem.
Instead of booleans (or STI), you can also use a state machine (last week pro episode ;-)) to keep track of the user's status (guest, registered user, admin...), for instance as describe in this railstips blog (this example modeli{s,z}es an inactive/active/abusive user).
You might have trouble authenticating with Google, under sessions/new.html.erb on line 30 replace:
a href="/auth/google_apps" class="auth_provider"
with
a href="/auth/google_oauth2" class="auth_provider"
Hey thanks so much for sharing your code Spencer, it really helped me with customizing this episode to my project. You're awesome!
It has been extracted to transitions gem, even before rails 3 came out.
No offense but, using a gem is fine but dont you think you could write it from scratch so you dont work 1 day of adding a feature to it? It will take you a couple of hours to write authentication from scratch.
Ryan, I'm a new rails dev and your screencasts are the best resource! Thanks for making them easy to get and search!
While following this screencast I was getting:
undefined method `visit' for #...
For my test. Turns out the current versions of Rspec and Capabara have moved the auto include of Capybara's DSL to only be included in the 'features' space of the spec tests.
You can either do the Capybara 'visit' (and other methods) into only the features tests or you can add Capybara's DSL to the request scope.
I chose to add the DSL to request scope so I could follow along.
in spec/spec_helper.rb
RSpec.configure do |config|
...
config.include Capybara::DSL, :type => :request
...
end
Hope this helps other noobs!
Interesting to see you don't use cucumber :) I don't use it.
By STI you are extending the the parent eg. all validations are inherited. I think that there is not simple way how to override validation.
Instead of playing with booleans to change objects behaviors, what you guys think about STI?
Personally, I'd made the
Guest
class as a subclass ofUser
. It's then possible to override behavior (validations, methods, etc.) without any uglyif
. It sounds more OO to me. Am I right?Hi HuffModdy,
That's pretty much what I was trying to do :), thanks for putting me back on the way :).
For those who try the same, don't forget to add some logic to give back his session to the user if he cancels the signin or sinup for any reason (he returns to the homepage, for instance).
Something like this should do the trick (before_filter in application controller)
I wrote an article on doing this but in my solution, upon registering I just updated the current anonymous user instead of creating a new one and transferring all their data.
http://highgroove.com/articles/2012/10/09/lazy-user-registration-for-rails-apps.html
I will add "reject_if" for the "accepts_nested_attributes_for" method for, ( for example) omit some attributes (for example blank attributes)
When you modified the session new page (i.e. changing the email address for username), it is possible that you forgot to change the password_field for a text_field. This might explain what you see.
There's no problem with destroying the guest user, just call reload first.
Although you would still need the rake tasks for users who never become members.
Any idea on how to implement with postgresql
and the relative scope in Order model
You could store the guest_user_id as a session variable, logout the guest then direct them to a sign up form. After that, generate the devise registrations controller, and do something along the lines of:
Hope this helps!
Thanks a lot Ryan for this great episode (one more :).
I'm just fighting a bit with Devise, and after a day sweating, I'm asking for help. First, here's the way I went, it could help some other folks around:
- I duplicated Devise Validatable class to apps/models/devise/models/validatable.rb, and patched the validation function to check for guest (password_required? and email_required? + created a custom one to ignore the validates_format_of :email as I store a uuid instead of an email for my guests, a bit dirty but efficient :)
- I then patched some of my controller on actions where I want to create a guest user on the fly (ex: if you create a content) and used sign_in_and_redirect(:user, my_new_gest_user) to log the guest in after creation.
The whole thing works fine, I start as anonymous, go to add a content, my patched controller does the job and I end-up as a guest user, logged in and with a content. I can then play with my app and create other pieces of content, works fine.
BUT (there is a but :) I'm stuck with the step where I need to create a new user if the guest wants to actually sign_up. Devise will refuse any sign_in or sign_up action, which makes sense as I'm kind of knocking on a door which is already opened :). Here I must admit I'm limited by my still-partial knowledge of Rails. I have the intuition I should override Devise controller to pass it as a parameter my guest_user.id, and tell him "Be nice, store this somewhere and let me signup" so I could then post-process it with something like your move_to method... but I can't find my way through Devise.
If anybody has gone through, I'll be glad to have a few crisps of advise to follow :).
Night here in Europe, I'll sleep on my code, cheers to those still working somewhere else :).
Thanks for another great screencast, Ryan.
Something to keep in mind: the
/announcements/:id/hide
route will fail with a 500 error if visited directly, as there is no request.referer in that case. This should be checked by the controller and redirect to a default url in that case, or maybe render a 404.Also, I would add rel="nofollow" to the link, so that spider bots don't follow it.
I am in charge of a relatively large app, which for the better part does not use ajax loading of content, I can see turbolinks being perfect for that. As other commentators have mentioned if you have already gone down the PJAX or Ajax Content loading route it might be more hassle than its worth.
Hi Ryan,
I seek advice about configuring the domain length, different for staging and production. I have an app that uses subdomain. The same app is hosted in a staging environment and production environment on the same server.
stagin paths:
http://staging.example.com
http://staging.example.info
http://staging.other-example.com
production paths:
http://example.com
http://example.info
http://other-example.com
The TLD length is 1, but how can i set the Domain length, so that in staging the domain length is 2 and in production the domain length is 1
Thanks in advance!
Marek
Yeah, it's great. I had to implement something similar a few years back but I managed to make it whey too complicated, Ryan's solution is much simpler!
Interesting.
Intuitively I'd say it has a big positive impact, but I confess it's only a gut feeling as I've never monitored such things.
I'd be very interested in seeing actual numbers. Is there some literature out there about this?
Thank you for the video. I must admit though, I'm not a fan of this approach - numerous experiments have proved that this approach doesn't really improve conversions.
This would brie exactly what I was looking for, I was just thinking about how to do this on another app. I think stripe does this, seems great from usability perspective