Stripe error while creating customer: You passed an empty string for 'card'. We
assume empty values are an attempt to unset a parameter; however 'card' cannot b
e unset. You should remove 'card' from your request or supply a non-empty value
Turn Off Turbolinks - wrap your links to the subscription form with no-data-turbolink. Turbrolinks is not re-loading the subscription.js.coffee on page load, so the code dosen't load the card values.
Also a couple of gotcha's was default scope and multiple includes.
We had to run the text_search as 'unscoped.where' and remove a couple of includes before any search results would displayed.
This app had one search query only on strings such as names, usernames, and email addresses (no full text searches). so we incorporated Ryan's Auto Completion:
How to have only active announcement ids in the cookies.signed[:hidden_announcement_ids]
This is kind of 'amateur hour' code (my specialty), but:
After using site-wide-announcements for several months, the development log was passing several dozen expired ids on each page load:
SELECT "announcements".*
FROM "announcements"
WHERE (starts_at <= '2013-03-18 06:55:20.343948' and ends_at >= '2013-03-18 06:55:20.343948')
AND (id not in (10,9,23,45,32,12,6,7,8,76,4,8,90,5,43,2,67,54,3,2,6,5,67,89,2,8,9,7,54,6,7,32,24,56,77,7,53,2,1))
ORDER BY id desc
I got tired of looking at all those ids, so as a test I tried to figure out how to have only active announcement ids in the cookies.signed[:hidden_announcement_ids].
Deleting the cookie was simple, but would re-display previously hidden announcements.
Here's my solution.
An 'active' name scope (id in (?)), as opposed to the 'current' scope (id not in (?))
models/announcement.rb
defself.active(hidden_ids = nil)
result = where("starts_at <= :now and ends_at >= :now", now:Time.zone.now)
result = result.where("id in (?)", hidden_ids) if hidden_ids.present?
result
end
An after_filter :flush_announcement_cookie, placed on the users' login landing dashboard_controller.
dashboard_controller
after_filter :flush_announcement_cookie
def flush_announcement_cookie
if cookies.signed[:hidden_announcement_ids].present?
ids = Announcement.active(cookies.signed[:hidden_announcement_ids]).pluck(:id)
cookies.permanent.signed[:hidden_announcement_ids] = ids
end
end
Here's a simple multi-rating system for Photos based of Ryan's videocast. It is simple: just pass the value as the params[:type]: vote_photo_path(photo, type: "1"). Aalso using twitter/bootstrap/font_awesome for the vote icons
vote:
Notice the current_user cannot vote on their own photos;
And I included a 'status' attribute for 'Approved' or 'Denied' the display/hide the photo from public viewing.
Automatic Quality Control: Notice the automatic status change to 'Denied' is ONLY after 10 votes and with an average value less than 3.
vote_range:
This is in the application_controller.rb because I use the reputation system on several models: Ads, Photos, Profiles.
defvote@photo = Photo.find(params[:id])
if current_user
if@photo.user_id != current_user.id
value = params[:type]
if vote_range?(value)
@photo.add_or_update_evaluation(:review_photos, value, current_user)
end# if low score on photo - automatically update status to "Denied" to hide from "Public" - @photos = Photo.publicif@photo.reputation_for(:review_photos).to_i < 3 && @photo.evaluations.count >= 10@photo.status = "Denied"@photo.save
endendend
respond_to do |format|
format.html { redirect_to :back, notice:"Thank you for voting" }
format.js
endenddefvote_reset@photo = Photo.find(params[:id])
if@photo.present?
evaluations = @photo.evaluations
evaluations.each do |eval|
eval.destroy
end
reputations = @photo.reputations
reputations.each do |rep|
rep.destroy
end@photo.status = "Approved"@photo.save
end
controllers/application_controller.rb
defvote_range?(value)
value.to_i.between?(-3,10)
end
helper_method :vote_range?defvotable?if user_signed_in?
if add - your - criteria - for example...
if current_user.status == "Approved"trueendendendend
helper_method :votable?
The content_tag_for was available in Rails 3 and 4. It has been removed from Rails 5.
To bypass content_tag_for try this simple format - it works for me with Ruby 5:
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.
if you are getting empty values:
Stripe error while creating customer: You passed an empty string for 'card'. We
assume empty values are an attempt to unset a parameter; however 'card' cannot b
e unset. You should remove 'card' from your request or supply a non-empty value
Drove me crazy!
Hey Jorge,
You should be able to include cities if you had a "cities.csv" which matched the states structure.
To answer the other part of your question:
The "states.csv" and "countries.csv" data files are available in the github hosted "Source Code" under the "Show Notes" header:
https://github.com/railscasts/088-dynamic-select-menus-revised
By using the "db/seeds.rb" file you can migrate the data into any rails app.
bundle exec rake db:seeds
I hope this helps for future use.
Hey Wayne,
The "states.csv" and "countries.csv" data files are available in the github hosted "Source Code" under the "Show Notes" header:
https://github.com/railscasts/088-dynamic-select-menus-revised
By using the "db/seeds.rb" file you can migrate the data into any rails app.
bundle exec rake db:seeds
I hope this helps for future use.
P.S.
My code is a little different:
First, I got carrierwave working as per 253-carrierwave-file-uploads
then..
Hey All,
Bootstrap 3 modifications:
And then
I hope this helps. I f'd around with this for hours install all new css, js files before it dawned on me to update the bootstrap css.
To Your Success!!! Mark
Hey... ... extremely late on this one - but just started a new app and needed reputation with pagination
By placing the "find_with_reputation" after pagination (will_paginate) works.
Try bbarton's suggestion - it worked for us.
Also a couple of gotcha's was default scope and multiple includes.
We had to run the text_search as 'unscoped.where' and remove a couple of includes before any search results would displayed.
This app had one search query only on strings such as names, usernames, and email addresses (no full text searches). so we incorporated Ryan's Auto Completion:
http://railscasts.com/episodes/102-auto-complete-association-revised
It works great. Thank's Ryan!
A big thank you - worked for me
A BIG Thank You! - Worked for me!
After upgrading to the latest jquery and adding Facebook 'Like' buttons, the sign-in popup window stopped functioning.
Firebug reported:
FB.getLoginStatus() called before calling FB.init().
To fix this, just move the "FB.init" call to the last position in facebook.js.coffee.erb.
Worked for me - not sure why.
A BIG Thank You Egbert! - Worked for me!
Maybe this can help those like Michael Elfassy, SMnetserv, pbaileyjr12 who have difficulty with double named countries.
On my app, everything worked fine until I accidentally 'bundle update' the gems.
After the bundle update, the double name countries (United States and United Kingdom) would not trigger and display the:
grouped_collection_select :state_id, Country.approved.includes(:states)
sidenote: bullet says to include states in the query.
I hope this helps:
How to have only active announcement ids in the cookies.signed[:hidden_announcement_ids]
This is kind of 'amateur hour' code (my specialty), but:
After using site-wide-announcements for several months, the development log was passing several dozen expired ids on each page load:
I got tired of looking at all those ids, so as a test I tried to figure out how to have only active announcement ids in the cookies.signed[:hidden_announcement_ids].
Deleting the cookie was simple, but would re-display previously hidden announcements.
Here's my solution.
An 'active' name scope (id in (?)), as opposed to the 'current' scope (id not in (?))
An after_filter :flush_announcement_cookie, placed on the users' login landing dashboard_controller.
Hope this helps somebody.
Here's a simple multi-rating system for Photos based of Ryan's videocast. It is simple: just pass the value as the params[:type]: vote_photo_path(photo, type: "1"). Aalso using twitter/bootstrap/font_awesome for the vote icons
vote:
Notice the current_user cannot vote on their own photos;
And I included a 'status' attribute for 'Approved' or 'Denied' the display/hide the photo from public viewing.
Automatic Quality Control: Notice the automatic status change to 'Denied' is ONLY after 10 votes and with an average value less than 3.
vote_range:
This is in the application_controller.rb because I use the reputation system on several models: Ads, Photos, Profiles.
vote_reset:
This allows for resetting the values.
voteable?:
Allows control of who can vote
I hope this helps
For ajax voting...
http://railscasts.com/episodes/136-jquery-ajax-revised
... it was very simple to setup.
Hey if you get: undefined method `reputation_value_for'
change `reputation_value_for' to 'reputation_for'
reputation_value_for was deprecated and replaced by reputation_for, see commit (10/03/2012)
reputation_for(reputation_name, *args)
https://github.com/twitter/activerecord-reputation-system/commit/552c04b0dead76cd79fb3915845b17b6a8de0cca
Also normalized_reputation_value_for was deprecated and replaced by normalized_reputation_for
normalized_reputation_for(reputation_name, *args)