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
[alias] | |
co = checkout | |
st = status -sb | |
br = branch | |
ci = commit | |
fo = fetch origin | |
d = !git --no-pager diff | |
dt = difftool | |
stat = !git --no-pager diff --stat |
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
{ | |
"window.zoomLevel": 0, | |
"editor.fontSize": 16, | |
"editor.tabSize": 2, | |
"window.openFilesInNewWindow": "off", | |
"files.insertFinalNewline": true, | |
"ruby.lint": { | |
"rubocop": true, | |
"ruby": true | |
}, |
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
<div class="row"> | |
<div class="col-sm-6 col-md-6"> | |
1ere colonne | |
</div> | |
<div class="col-sm-6 col-md-6"> | |
2eme colonne | |
</div> | |
</div> |
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
irb(main):011:0> Product.where("name_translations->>'en' = ?", "My great product").first | |
=> #<Product id: 1, sku: "SKU", name_translations: ... |
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
def product_params | |
params.require(:product).permit(:sku, name_translations: I18n.available_locales) | |
end |
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
<%= fields_for "product[name_translations]", OpenStruct.new(product.name_translations) do |translation_fields| %> | |
<% I18n.available_locales.each do |locale| %> | |
<div class="field"> | |
<%= translation_fields.label locale, "Name #{locale}" %> | |
<%= translation_fields.text_field locale %> | |
</div> | |
<% end %> | |
<% end %> |
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
p = Product.new | |
p.name_translations = {"en" => "My great product", "fr" => "Mon super produit"} | |
p.name_translations["en"] | |
#=> "My great product" |
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 CreateProducts < ActiveRecord::Migration[5.1] | |
def change | |
create_table :products do |t| | |
t.string :sku | |
t.json :name_translations, default: {} | |
t.json :description_translations, default: {} | |
t.timestamps | |
end |
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
<script> | |
export default { | |
name: 'hello', | |
methods: { | |
removeProperty (productProperty) { | |
this.product_properties.splice(this.product_properties.indexOf(productProperty), 1) | |
}, | |
addProperty () { | |
this.product_properties.push({ name: '', value: '' }) | |
} |
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
def add(conn, %{"product_id" => product_id}) do | |
product = Front.get_product!(product_id) | |
conn = case conn.assigns[:current_order] do | |
nil -> | |
order = Front.create_order_with_product!(product) | |
conn |> put_session(:order_id, order.id) | |
order -> | |
Front.add_product_to_order!(order, product) | |
conn |