This is not a solution for your specific problem, but I'm performing the same integration using the gem 'paypal-sdk-rest' which helps to connect to the Paypal REST API.
With this gem you can create a Payment using the payment_method: 'paypal' which behaviour is similar to the express checkout of the classic API.
This is a simple working test code, hope it helps:
def paypal_return
p= PayPal::SDK::REST::Payment.find(params[:paymentId])
# at this point p.state == 'created'
if p.execute(payer_id: params[:PayerID])
if p.state == 'approved'
redirect_to your_success_path
else
redirect_to your_failure_path
end
else
redirect_to your_failure_path
end
end
To anyone who is looking for an easy Rails plus Angular setup, the gem Entangled might help. It's very easy to integrate and is basically ActiveRecord for Angular. It also syncs all changes to your database in real time across all connected clients.
how to upload multiple files using carrierwave
hi
i am using carrierwave gem for file upload. It is working fine with single upload, but how to upload multiple files please help me.
class AttachmentUploader < CarrierWave::Uploader::Base
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def extension_white_list
%w(xlsx pdf doc htm html docx png jpg jpeg xls)
end
def filename
"#{model.invoice_number}.#{file.extension}" if original_filename.present?
end
end
While Ryan is on his Sabbatical, I think it important to keep some of this information up-to-date with the changes. Ryan developed a well-deserved reputation and his RailsCasts are referenced just about anywhere you can google a rails problem/solution.
As such, I want to comment on a couple of things regarding this episode.
The strong_parameters gem is automatically implemented in this episode. This is confusing because the docs for s_p shows controller-level checking, which has now become the standard for all Rails 4 apps.
You may notice that there isn't a method permitted_params inside the application_controller. All whitelisting logic has been moved to the application controller via the authorize method, which calls current_permission. All strong_parameters checking is now handled by base_permission.rb inside the permit_params!(params) method and delegated to each of the permission classes - Admin, Member and Guest.
I found it very advantageous to rename some of Ryan's code. In the video, he recommends renaming the allow method to allow_action. DO THIS. Also, I took the liberty of renaming the allow_param method to allow_attribute, since that is what is being allowed and it removes identity confusion with the params hash.
All-in-all, this is a great starting point for any Rails-based app. All you need to do is fork the code from GitHub, include the rename gem to change the name of the app, and start building your models. For each model you include, go back and whitelist the appropriate attributes (model fields) with the appropriate authorizations (admin, guest, etc.) Voila! Instant authorization including mass-assignment protection.
Now, just pop on over to RC#250 (revised) and roll your own authentication. Both episodes merge without problems. Now you have a fully functional template for building just about anything.
So this railscast is great but I ran into problems with the config/initializers/doorkeeper.rb file. Instead of getting to the authorization pages I was redirected to the provider site homepage. I was able to fix this by using all the code shown here LINK
hello all, with rails 4, I could not pass the locals variable to the template handler : only the hask key was present in the strings array named template.locals
I created a rails github issue for that : https://github.com/rails/rails/issues/19204
For people following along with the code in this Railscast, the curl command has changed. Github redirects the 'raw.github.com' to 'raw.githubusercontent.com' now but the curl command doesn't follow the redirect.
There's no such thing as online users. One possible way would be to subscribe all users to a broadcast channel, and send them a message making them ping your server.
Also the new.js.erb title incorrectly has the view/templates directory and should be /app/views/tasks/new.js.erb instead of /app/templates/tasks/new.js.erb
Sounds as though you're phishing for their facebook password. I see where you may be coming from but answering this question would possibly lead to questionable behavior. Sorry, man.
As a general question Ryan, do you rehearse these until you can get them in one session or do you do a lot of edits. Just curious.
Or maybe you are just that good at it?
Either way tanks! Oops! Do you have a screen-cast showing how to use the new Rails4 error console?
Alan - the issue was in the product_types_controller, but your solution is in the products_controller. There might also be a problem in the products_controller, but initially, since product_types contains the :fields_attributes hash, the solution needs to be in permitting params[:product[:fields_attributes]] or somesuch. I notice the solution link you gave from stack makes the same mistake. Or, is it a mistake?
I've added all of the code up untill about 3:30 min in and it's successfully uploading the csv file but the rows aren't getting associated with a user.
I'm really struggling to figure out how to get this to work. Any help will be appreciated!
I've posted a full description of the issue to stack overflow.
*** very frustrated... want to use this and it is now feedjira and these issues are all over the internet with no solutions>>> please help... thanks
$ gem install feedjira
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing feedjira:
ERROR: Failed to build gem native extension.
checking for curl-config... no
checking for main() in -lcurl... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Try passing --with-curl-dir or --with-curl-lib and --with-curl-include
options to extconf.
extconf failed, exit code 1
Gem files will remain installed in c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/curb-0.8.6 for inspection.
Results logged to c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/extensions/x86-mingw32/2.0.0/curb-0.8.6/gem_make.
any solution? I'm looking to implement the same thing
This is not a solution for your specific problem, but I'm performing the same integration using the gem 'paypal-sdk-rest' which helps to connect to the Paypal REST API.
With this gem you can create a Payment using the payment_method: 'paypal' which behaviour is similar to the express checkout of the classic API.
This is a simple working test code, hope it helps:
Into a controller:
def test
p = PayPal::SDK::REST::Payment.new(
{
intent: 'sale',
payer: {
payment_method: 'paypal'
},
redirect_urls: {
return_url: paypal_return_url,
cancel_url: your_cancel_url
},
transactions: [
{
amount: {
total: '1',
currency: 'USD'
},
description: "Test item'
}
]
}
)
if p.create
redirect_url = p.links.find{|v| v.method == 'REDIRECT'}.href
Rails.logger.info "Paypal Payment ID: #{p.id}"
Rails.logger.info "Redirect to: #{redirect_url}"
redirect_to redirect_url
else
Rails.logger.info p.error.inspect
end
end
def paypal_return
p= PayPal::SDK::REST::Payment.find(params[:paymentId])
# at this point p.state == 'created'
if p.execute(payer_id: params[:PayerID])
if p.state == 'approved'
redirect_to your_success_path
else
redirect_to your_failure_path
end
else
redirect_to your_failure_path
end
end
To anyone who is looking for an easy Rails plus Angular setup, the gem Entangled might help. It's very easy to integrate and is basically ActiveRecord for Angular. It also syncs all changes to your database in real time across all connected clients.
https://github.com/dchacke/entangled
Hello,
in 2015, There are some new issues in your encrypted paypal button.
Since december 2014, Paypal security is using TLS and no longer SSL due to its recent vulnerabilities.
So what will be the new ruby Syntax and/or configuration for encrypting paypal form button in your function "encrypt_for_paypal(values)" ?
works again now
The video file seems to be broken (404 http://media.railscasts.com/assets/episodes/videos/268-sass-basics.mp4)
how to upload multiple files using carrierwave
hi
i am using carrierwave gem for file upload. It is working fine with single upload, but how to upload multiple files please help me.
This is my form:
attachment_uploader.rb:
I used http://richonrails.com/articles/allowing-file-uploads-with-carrierwave for refernce.
I'm getting the following error when I load any page of my app:
undefined method `scope_schema' for nil:NilClass when users session creation
any body have idea about this
While Ryan is on his Sabbatical, I think it important to keep some of this information up-to-date with the changes. Ryan developed a well-deserved reputation and his RailsCasts are referenced just about anywhere you can google a rails problem/solution.
As such, I want to comment on a couple of things regarding this episode.
The
strong_parameters
gem is automatically implemented in this episode. This is confusing because the docs for s_p shows controller-level checking, which has now become the standard for all Rails 4 apps.You may notice that there isn't a method
permitted_params
inside theapplication_controller
. All whitelisting logic has been moved to the application controller via theauthorize
method, which callscurrent_permission
. All strong_parameters checking is now handled bybase_permission.rb
inside thepermit_params!(params)
method and delegated to each of the permission classes - Admin, Member and Guest.I found it very advantageous to rename some of Ryan's code. In the video, he recommends renaming the
allow
method toallow_action
. DO THIS. Also, I took the liberty of renaming theallow_param
method toallow_attribute
, since that is what is being allowed and it removes identity confusion with the params hash.All-in-all, this is a great starting point for any Rails-based app. All you need to do is fork the code from GitHub, include the
rename
gem to change the name of the app, and start building your models. For each model you include, go back and whitelist the appropriate attributes (model fields) with the appropriate authorizations (admin, guest, etc.) Voila! Instant authorization including mass-assignment protection.Now, just pop on over to RC#250 (revised) and roll your own authentication. Both episodes merge without problems. Now you have a fully functional template for building just about anything.
Mark. I literally almost went nuts. 2+ hours just trying to get the card to push up to stripe. Turbolinks was my issue. Thank you so much.
Genius, thank you very much.
I have been getting the same problem
http://stackoverflow.com/questions/29056608/sidekiq-worker-class-not-working-with-carrierwave-upload
Whoever watches this and prefers pushing over polling, check out https://github.com/dchacke/entangled
Entangled is a Rails gem that pushes data changes to all clients in real time. Maybe it helps someone!
How did you end up solving the aggregation problem?
Hello migane,
Do you have any updated information on highcharts as this comment was made 3+ years ago? Thank you, BBa
100.times
puts "*********Thank You************************"
end
Awesome Job
Hats off Ryan.
params doesn't return all of this now (Rails 4.2). params only returns the action and controller and an id if applicable.
What do you do now? Parse the url?
So this railscast is great but I ran into problems with the config/initializers/doorkeeper.rb file. Instead of getting to the authorization pages I was redirected to the provider site homepage. I was able to fix this by using all the code shown here
LINK
find_all_by_complete.... is not working for me..
can u please tell me what might be the problem...
can someone help me?
How is it possible to add the filename as a new column in the database?
Thanks for this man!!!
I am pretty sure I had the same problem. In your _condition_fields.html.erb did you make sure to surround everything with:
It is triggering on that div I believe.
<%= f.hidden_field :product_type_id %>
should be
Have you inserted
<%= f.hidden_field :tracker_type_id %>
in the app/views/products/_form.html.erb
You have a wrong gem, the correct gem is:
gem 'foundation-rails'
And not:
gem 'zurb-foundation'
hello all, with rails 4, I could not pass the locals variable to the template handler : only the hask key was present in the strings array named template.locals
I created a rails github issue for that :
https://github.com/rails/rails/issues/19204
Just ran into this as well. Anyone found a decent workaround?
For people following along with the code in this Railscast, the curl command has changed. Github redirects the 'raw.github.com' to 'raw.githubusercontent.com' now but the curl command doesn't follow the redirect.
Or if you don't trust me (you shouldn't), then tell curl to follow redirects with the -L option and use Ryan's curl command instead:
There's no such thing as online users. One possible way would be to subscribe all users to a broadcast channel, and send them a message making them ping your server.
How to show online users ?
Check out how I load YAML file config for a basic http authentication in my tutorial
http://aflexsystem.com/how-to-create-a-simple-admin-control-panel-with-ruby-on-rails-in-less-than-9-minutes/
You can use
to check if the file exists first.. and set your heroku variables manually
I just wrote a gem to implement real time behavior in a Rails app à la Firebase: https://github.com/so-entangled/rails
I was hoping to make it a little simpler than private pub - I'd greatly appreciate your feedback!
Also the new.js.erb title incorrectly has the view/templates directory and should be /app/views/tasks/new.js.erb instead of /app/templates/tasks/new.js.erb
e.g.
$('#new_link').hide().after('<%= j render("form") %>');
Sounds as though you're phishing for their facebook password. I see where you may be coming from but answering this question would possibly lead to questionable behavior. Sorry, man.
Checkout
ngrok.com
Once setup, running a subdomain is as easy as:
ngrok -subdomain=mysubdomain 3000
https://mysubdomain.ngrok.com -> 127.0.0.1:3000
http://mysubdomain.ngrok.com -> 127.0.0.1:3000
I used it to test PayPal's IPN for recurring subscriptions.
Checkout
ngrok.com
Once setup, running a subdomain is as easy as:
ngrok -subdomain=mysubdomain 3000
https://mysubdomain.ngrok.com -> 127.0.0.1:3000
http://mysubdomain.ngrok.com -> 127.0.0.1:3000
I used it to test PayPal's IPN for recurring subscriptions.
Hello all, I'm currently following this guide and I'm running into a problem with the first remove answers step.
<%= f.label :content, "Answer" %>
<%= f.text_field :content %>
<%= f.hidden_field :_destroy %>
<%= link_to "remove", '#', class: "remove_fields" %>
jQuery ->
$('form').on 'click', '.remove_fields', (event) ->
$(this).prev('input[type=hidden]').val('1')
$(this).closest('fieldset').hide()
event.preventDefault()
when I go to test this and click on the "remove" link nothing is hidden. when I submit the form it doesn't remove the answer. Any thoughts?
As a general question Ryan, do you rehearse these until you can get them in one session or do you do a lot of edits. Just curious.
Or maybe you are just that good at it?
Either way tanks! Oops! Do you have a screen-cast showing how to use the new Rails4 error console?
I want to get response from this event method using rest client. It does not response. Is the Redis subscribe method create any problem for Restcleint ? I make question in here also http://stackoverflow.com/questions/28485446/rest-client-not-working-for-rails-server-sent-eventsse
Alan - the issue was in the product_types_controller, but your solution is in the products_controller. There might also be a problem in the products_controller, but initially, since product_types contains the :fields_attributes hash, the solution needs to be in permitting params[:product[:fields_attributes]] or somesuch. I notice the solution link you gave from stack makes the same mistake. Or, is it a mistake?
Nested attributes will need updating too:
http://stackoverflow.com/questions/18436741/rails-4-strong-parameters-nested-objects
guys
in rails 4.2 not work for me
https://github.com/thiagovsk/raffler_rails_angularjs
this works, thanks!
I've added all of the code up untill about 3:30 min in and it's successfully uploading the csv file but the rows aren't getting associated with a user.
I'm really struggling to figure out how to get this to work. Any help will be appreciated!
I've posted a full description of the issue to stack overflow.
http://stackoverflow.com/questions/28347026/associating-rows-from-uploaded-csv-files-with-a-user-in-rails
Mind you: In rails 4 dont use attr_accessible in the model, instead in the controller add:
ehh this took me an hour to figure out :)
ps: nice to add this in the modell though:
how can I use will_paginate with ajax for this.
You need to install curl and make sure curl.h is available to your compiler path.
How deploy that?
What specify in deploy.rb or how call lib/taks/resque.rake
*** very frustrated... want to use this and it is now feedjira and these issues are all over the internet with no solutions>>> please help... thanks
$ gem install feedjira
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing feedjira:
ERROR: Failed to build gem native extension.
checking for curl-config... no
checking for main() in -lcurl... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=c:/RailsInstaller/Ruby2.0.0/bin/ruby
--with-curl-dir
--without-curl-dir
--with-curl-include
--without-curl-include=${curl-dir}/include
--with-curl-lib
--without-curl-lib=${curl-dir}/
--with-curllib
--without-curllib
extconf.rb:18:in `': Can't find libcurl or curl/curl.h (RuntimeError)
Try passing --with-curl-dir or --with-curl-lib and --with-curl-include
options to extconf.
extconf failed, exit code 1
Gem files will remain installed in c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/curb-0.8.6 for inspection.
Results logged to c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/extensions/x86-mingw32/2.0.0/curb-0.8.6/gem_make.
Don't miss a better alternative: Que.