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
| class ApplicationController < ActionController::Base | |
| # Prevent CSRF attacks by raising an exception. | |
| # For APIs, you may want to use :null_session instead. | |
| protect_from_forgery with: :exception | |
| private | |
| def current_cart | |
| @current_cart ||= begin | |
| Cart.find(session[:cart_id]) |
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 form_for_login(&block) | |
| form_for(resource, | |
| as: resource_name, | |
| url: session_path(resource_name), | |
| html: { | |
| class: 'navbar-form navbar-right', | |
| role: 'login' | |
| }, &block) | |
| end | |
| 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
| class Challenge < AR::Base | |
| belongs_to :category | |
| has_many :participations | |
| has_many :participants, through: :participations | |
| 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
| <div class="chatboxinput"> | |
| <%= form_for([@conversation, @message], :url => conversation_messages_path(@conversation, @message, format: 'js'), :remote => true, :html => {id: "conversation_form_#{@conversation.id}"}) do |f| %> | |
| <%= f.text_area :body, class: "chatboxtextarea", "data-cid" => @conversation.id %> | |
| <%= hidden_field_tag :authenticity_token, form_authenticity_token %> | |
| <% end %> | |
| </div> |
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
| class NotePolicy < ApplicationPolicy | |
| # For index action | |
| class Scope | |
| attr_reader :user, :scope | |
| def initialize(user, scope) | |
| @user = user | |
| @scope = scope | |
| 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
| class CreateCategories < ActiveRecord::Migration | |
| def change | |
| create_table :categories do |t| | |
| t.string :name | |
| t.timestamps | |
| end | |
| end | |
| 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
| class CreateGroupLocations < ActiveRecord::Migration | |
| def change | |
| create_table :group_locations do |t| | |
| t.belongs_to :address, index: true, foreign_key: true | |
| t.belongs_to :group, index: true, foreign_key: true | |
| t.timestamps null: false | |
| end | |
| end | |
| 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
| urls.each do |url| | |
| begin | |
| open(url) | |
| # do some nokogiri things | |
| rescue OpenURI::HTTPError | |
| # log the error | |
| end | |
| 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
| if params[:friend_id] | |
| friend = User.find(params[:friend_id]) | |
| else | |
| # ... | |
| 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
| Rails.application.routes.draw do | |
| resources :categories | |
| devise_for :admins | |
| devise_for :users | |
| resources :users | |
| namespace :admin do | |
| resources :categories | |
| end | |