This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= select(:post, :category, Post::CATEGORIES, :disabled => 'private') %> | |
<!— Give's you something like —> | |
<select name="post[category]"> | |
<option>story</option> | |
<option>joke</option> | |
<option>poem</option> | |
<option disabled="disabled">private</option> | |
</select> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= options_from_collection_for_select(@product.sizes, :name, :id, :disabled => lambda{|size| size.out_of_stock?}) %> | |
<!-- If small and medium returned true for the method out_of_stock?, you’d get something like: --> | |
<option value=“23“ disabled=“disabled“>small</option> | |
<option value=“24“ disabled=“disabled“>medium</option> | |
<option value=“25“>large</option> | |
<option value=“26“>extra large</option> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= options_for_select( | |
['Choose a size', 'small', 'medium', 'large'], | |
nil, # selected value | |
'medium' # disabled value | |
) %> | |
<!-- Gives you --> | |
<option value="Choose a size">Please choose a size</option> | |
<option value="s">small</option> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= options_from_collection_for_select( | |
@products, | |
:id, | |
:name, | |
nil, # selected value(s) | |
lambda{|p| !p.in_stock? } # disabled value(s) identified with a proc | |
) %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git fetch origin other_branch:other_branch | |
* [new branch] other_branch -> other_branch | |
git branch | |
* master | |
other_branch | |
git checkout other_branch | |
# Or, in one swift command: | |
git checkout -t origin/other_branch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gateway = ActiveMerchant::Billing::ProtxGateway.new({ | |
:login => 'test', | |
:password => 'password', | |
:enable_3d_secure => true | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
response = gateway.purchase(100, credit_card) | |
if response.success? | |
puts "Purchase successfully made" | |
else | |
puts "Purchase not authorised, try again" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
response = gateway.purchase(100, credit_card) | |
if response.success? | |
puts "Purchase successfully made" | |
elsif response.three_d_secure? | |
puts "Purchase requires additional 3D Authentication" | |
else | |
puts "Purchase not authorised, try again" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
response = gateway.three_d_complete(pa_res, md) | |
if response.success? | |
puts "Authentication complete and purchase successfully made" | |
else | |
puts "Purchase not authorised or authentication failed, try again" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
@credit_card = ActiveMerchant::Billing::CreditCard.new(params[:credit_card]) | |
@billing_address = Address.new(params[:address]) | |
@payment = @order.payments.create(:credit_card => @credit_card, :address => @billing_address) | |
if @payment.success? | |
redirect_to complete_order_url(@order) | |
elsif @payment.requires_authentication? | |
# A view with an iframe from which the user is redirected to the authentication page | |
render :action => 'three_d_iframe' | |
else |
OlderNewer