Skip to content

Instantly share code, notes, and snippets.

@apeniche
apeniche / gist:d150dd7218dd35c26963
Created September 2, 2015 20:48
Change language
// This goes in the application controller
before_action :set_locale
def set_locale
if current_user and current_user.locale
I18n.locale = current_user.locale[0..1]
else
if session[:lang]
I18n.locale = session[:lang]
else
@apeniche
apeniche / routes.rb
Created February 10, 2015 16:55
app/main/config/
# See https://github.com/voltrb/volt#routes for more info on routes
# Routes for login and signup, provided by user-templates component gem
get '/signup', _controller: 'user-templates', _action: 'signup'
get '/login', _controller: 'user-templates', _action: 'login'
# The main route, this should be last. It will match any params not
# previously matched.
get '/', {}
@apeniche
apeniche / main_controller.rb
Created February 10, 2015 16:54
app/main/controllers/
# By default Volt generates this controller for your Main component
class MainController < Volt::ModelController
model :store
def index
end
def send_message
unless page._new_message.strip.empty?
_messages << { sender_id: Volt.user._id, receiver_id: params._user_id, text: page._new_message }
@apeniche
apeniche / main.html
Created February 10, 2015 16:53
app/main/views/main/
<:Title>
{{ template main_path, "title", {controller_group: 'main'} }}
<:Body>
<div class="container">
<div class="header">
<ul class="nav nav-pills pull-right">
<:nav href="/" text="Home" />
<:user-templates:menu />
</ul>
@apeniche
apeniche / index.html
Created February 10, 2015 16:52
app/main/views/main/
<:Title>
Home
<:Body>
<h1>Home</h1>
{{ if Volt.user }}
<div class="row">
<div class="col-md-4">
{{ _users.each do |user| }}
{{ if user._id != Volt.user._id }}
@apeniche
apeniche / app.css.scss
Created February 10, 2015 16:51
app/main/assets/css/
.conversation{
form{
input{
margin: 10px 0 5px 0;
}
}
}
.contact{
width:100%;
@apeniche
apeniche / app.css.scss
Created February 5, 2015 14:49
A step by step guide to your first Volt app
.conversation{
form{
input{
margin: 10px 0 5px 0;
}
}
}
.contact{
width:100%;