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
As of 8/25/2013, The following steps will create an ecommerce Rails application using the latest stable version of Spree. | |
1) cd railsprojects | |
2) rvm use 1.9.3@spree --create | |
3) gem install rails -v=3.2.14 --no-ri --no-rdoc | |
4) rails new mystore -d mysql | |
5) cd mystore | |
6) Add the following to the Gemfile | |
gem 'spree', '2.0.4' |
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
var data = inputs.serializeArray(); | |
var option_types_url = window.location.protocol + "//" + window.location.host + "/" + 'api/option_types?'; | |
$.get(option_types_url, { ids: data[3].value} ).done(function(option_types) { | |
console.log(option_types_url); | |
console.log(option_types); | |
}); |
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
var get_types = function() { | |
var data = inputs.serializeArray(); | |
var option_types_url = window.location.protocol + "//" + window.location.host + "/" + 'api/option_types?'; | |
$.get(option_types_url, { ids: data[3].value} ).done(function(option_types) { | |
console.log(option_types_url); | |
console.log(option_types); | |
}); | |
}; |
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
// Reload types by AJAX POST | |
$form.submit(function (event) { | |
event.preventDefault(); | |
var data = $form.serialize(); | |
$.ajax({ | |
type: "POST", | |
url: form_action, | |
dataType: "json", | |
data: data, | |
success: function (json) { |
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
var ids = undefined; | |
$(document).ready(function () { | |
var $form = $("form.edit_product"); | |
var form_action = $form.attr("action"); | |
var product_name_id = form_action.split('/')[3]; | |
var option_types_url = window.location.protocol + "//" + window.location.host + "/" + 'api/products/' + product_name_id; | |
$form.submit(function(e, data){ | |
e.preventDefault(); | |
$.ajax({ |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>My Rails App</title> | |
<%- if protect_against_forgery? -%> | |
<meta name="authenticity-token" id="authenticity-token" content="<%= form_authenticity_token %>" /> | |
<%- end -%> | |
<%= javascript_include_tag 'jquery', 'rails' %> | |
</head> | |
<body> |
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
var fetch_accordion = function() { | |
$.getJSON(api_url + 'products/' + product_name_id, null).done(function(json) { | |
var ids = ""; | |
for (var key in json.option_types) { | |
ids += json.option_types[key].id + "," | |
} | |
$.getJSON(api_url + 'option_types/', {ids: ids} ).done(function(json) { | |
console.log(json); | |
}); | |
}); |
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
var $form = $("form.edit_product"); | |
var form_action = $form.attr("action"); | |
var product_name_id = form_action.split('/')[3]; | |
var api_url = window.location.protocol + "//" + window.location.host + '/api/'; | |
$form.submit(function (e, data) { | |
e.preventDefault(); | |
$.ajax({ | |
url: form_action, | |
dataType: "json", | |
type: "post", |
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
<style> | |
.select2-container.select2-container-multi { | |
width: 100%; | |
} | |
</style> | |
<%= form_for [:admin, @product], :method => :put, :html => {:multipart => true} do |f| %> | |
<fieldset class="no-border-top"> | |
<%= f.field_container :option_types do %> | |
<%= f.label :option_type_ids, Spree.t(:option_types) %> |
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
# db/migrate/01_add_custom_admin_roles.rb | |
class AddCustomAdminRoles < ActiveRecord::Migration | |
@roles = %w[extra] | |
def self.up | |
@roles.each do |r| | |
Role.create(:name => r) | |
end | |
end |
OlderNewer