This file contains 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
class OrdersController < ApplicationController | |
before_action :get_cart | |
# process order | |
def create | |
@order = Order.new(order_params) | |
# Add items from cart to order's ordered_items association | |
@cart.ordered_items.each do |item| | |
@order.ordered_items << item |
This file contains 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
puts 'hello world!' |
This file contains 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
module RenderHelper | |
def input_tag_for(field_name, opts = {}) | |
content_tag :fieldset do | |
content_tag(:label, :for => field_name) do | |
concat opts[:label] | |
[:error_text, :remote_error_text].each do |i| | |
(concat content_tag(:span, opts[i], :class => i)) if opts[i] | |
end | |
end | |
concat content_tag(:input, :id => field_name, :name => field_name) |