Skip to content

Instantly share code, notes, and snippets.

<h1> Add a route to this gym </h1>
<br>
<%= form_for :route, url: { action: "create" }, method: 'post' do |f| %>
<div class="field">
<%= f.label :route_identifier %><br>
<%= f.text_field :route_identifier %>
</div>
<div class="field">
<%= f.label :grade %><br>
class RoutesController < ApplicationController
def index
if params[:gym_id]
@gym = Gym.find(params[:gym_id])
@routes = Route.where("gym_id = #{@gym.id}")
elsif params[:user_id]
@user = User.find(params[:user_id])
@routes = Route.where("user_id = #{@user.id}")
else
def index
if params[:gym_id]
@gym = Gym.find(params[:gym_id])
@routes = Route.where("gym_id = #{@gym.id}")
elsif params[:user_id]
@user = User.find(params[:user_id])
@routes = Route.where("user_id = #{@user.id}")
else
@routes = Route.all
end
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)
## Creating users
require 'rails_helper'
require 'pry'
RSpec.describe UsersController, type: :controller do
before(:example) do
@climber = User.create!(email: 'climber@sendroute.com', password: '123456', first_name: 'test', last_name: 'test',
user_name: 'climber')
@setter = User.create!(email: 'setter@sendroute.com', password: '123456', first_name: 'test', last_name: 'test',
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
describe "GET #index" do
#describe "POST #create" do
#describe "GET #show" do
#describe "PATCH #update" do (or PUT #update)
#describe "DELETE #destroy" do
#describe "GET #new" do
require 'rails_helper'
RSpec.describe GymsController, type: :controller do
let(:gym) { Gym.create!(gym_name: "Stronghold gym", about: "Brand new bouldering gym in Tottenham Hale", address: "Tottenham Hale, London", email: "stronghold@gmail.com" )}
let(:climber) { User.create!(email: 'climber@sendroute.com', password: '123456', first_name: 'test', last_name: 'test', user_name: 'climber') }
let(:gym_create) {{ gym_name: "The Castle Gym", about: "Classic multi story climbing gym in central london", address: "Finsbury Park - London", email: "castleclimbing@gmail.com" } }
before do
sign_in(climber)
end
require 'rails_helper'
RSpec.describe GymsController, type: :controller do
let(:gym) { Gym.create!(gym_name: "Stronghold gym", about: "Brand new bouldering gym in Tottenham Hale", address: "Tottenham Hale, London", email: "stronghold@gmail.com" )}
let(:climber) { User.create!(email: 'climber@sendroute.com', password: '123456', first_name: 'test', last_name: 'test', user_name: 'climber') }
let!(:gym_create) {{ gym_name: "The Castle Gym", about: "Classic multi story climbing gym in central london", address: "Finsbury Park - London", email: "castleclimbing@gmail.com" } }
before do
sign_in(climber)
end
[10] pry(#<RSpec::ExampleGroups::GymsController::POSTCreate>)> post :create, params:{gym: gym_create
[10] pry(#<RSpec::ExampleGroups::GymsController::POSTCreate>)* }
not saved
=> #<ActionDispatch::TestResponse:0x0000000264c498
@cache_control={},
@committed=true,
@cv=#<MonitorMixin::ConditionVariable:0x0000000264a648 @cond=#<Thread::ConditionVariable:0x00000002649748>, @monitor=#<ActionDispatch::TestResponse:0x0000000264c498 ...>>,
@header={"X-Frame-Options"=>"SAMEORIGIN", "X-XSS-Protection"=>"1; mode=block", "X-Content-Type-Options"=>"nosniff", "Content-Type"=>"text/html; charset=utf-8"},
@mon_count=0,
@mon_mutex=#<Thread::Mutex:0x0000000264a9e0>,
[16] pry(#<RSpec::ExampleGroups::GymsController::POSTCreate>)> Gym.create!(gym_name: "Stronghold gym", about: "Brand new bouldering gym in Tottenham Hale", address: "Tottenham Hale, London", email: "stronghold@gmail.com" )
=> #<Gym:0x00000005caf670
id: 1,
routes_id: nil,
gym_name: "Stronghold gym",
about: "Brand new bouldering gym in Tottenham Hale",
address: "Tottenham Hale, London",
email: "stronghold@gmail.com",
created_at: Mon, 21 May 2018 11:26:25 UTC +00:00,
updated_at: Mon, 21 May 2018 11:26:25 UTC +00:00,