Skip to content

Instantly share code, notes, and snippets.

@chewmanfoo
Last active August 29, 2015 14:22
Show Gist options
  • Select an option

  • Save chewmanfoo/c629cb9b7ce81efb4d15 to your computer and use it in GitHub Desktop.

Select an option

Save chewmanfoo/c629cb9b7ce81efb4d15 to your computer and use it in GitHub Desktop.
problems with rails and javascript?
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
end
Started GET "/escrow-admin/escrow_sessions.self-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css?body=1" for 127.0.0.1 at 2015-06-12 12:02:13 -0500
Started GET "/escrow-admin/svn_repos.self-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css?body=1" for 127.0.0.1 at 2015-06-12 12:02:13 -0500
Started GET "/escrow-admin/welcome.self-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css?body=1" for 127.0.0.1 at 2015-06-12 12:02:13 -0500
Started GET "/escrow-admin/application.self-167193cd81d9330d9ddb5c4ec7b44214fea529aa8a94f3a86e6526e4f652fc02.css?body=1" for 127.0.0.1 at 2015-06-12 12:02:13 -0500
Started GET "/escrow-admin/foundation_and_overrides.self-a43df6fadc8dd9c69fbcdd5fba3619da2fa5cb0417dc4ac7b58571fc2c7f8e78.css?body=1" for 127.0.0.1 at 2015-06-12 12:02:13 -0500
Started GET "/escrow-admin/jquery.self-d03a5518f45df77341bdbe6201ba3bfa547ebba8ed64f0ea56bfa5f96ea7c074.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:13 -0500
Started GET "/escrow-admin/jquery_ujs.self-8e98a7a072a6cee1372d19fff9ff3e6aa1e39a37d89d6f06861637d061113ee7.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:13 -0500
Started GET "/escrow-admin/foundation/foundation.alert.self-fbde7afb61e8ffd8ab9b717f0bed1e58cb9e0144a25cc773fea634d5554f62cd.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:13 -0500
Started GET "/escrow-admin/foundation/foundation.interchange.self-dad8415355087cb21a16fa44bac20d602344d52de5aca9e588e3588fce5dd5a7.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:13 -0500
Started GET "/escrow-admin/foundation/foundation.magellan.self-a50193f172f11e57b373c3001072ba2d6b34b857ab251e9ded30af5242855687.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:13 -0500
Started GET "/escrow-admin/foundation/foundation.reveal.self-95f01feb3e25e47b58b78da0021ae2fffafdee70846682067c180e0e10f7b095.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:13 -0500
Started GET "/escrow-admin/foundation/foundation.topbar.self-105416f061562f07c6a0a8057d68282fdc1eeb5dc306713fcae6c9a53001fc55.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:13 -0500
Started GET "/escrow-admin/foundation.self-abe4ee7a105042f73b12b1f1a28788522d2f253445a475a94ab4d6e1f7b0ec52.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:13 -0500
Started GET "/escrow-admin/turbolinks.self-c37727e9bd6b2735da5c311aa83fead54ed0be6cc8bd9a65309e9c5abe2cbfff.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:13 -0500
Started GET "/escrow-admin/archives.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:13 -0500
Started GET "/escrow-admin/application.self-79a300d240bbf145c9af961805bc87f18e9f73bd1cda275895295c80d8552d3f.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:13 -0500
Started GET "/escrow-admin/vendor/modernizr.self-74da3245def7569da28115667be6a85a2ad97464abe707c9829c46d8975597bc.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:13 -0500
Started GET "/escrow-admin/foundation/foundation.self-ee5396739ce46beb039f26ea629172a74143752d74f703c6c3b219fc52aecf73.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:13 -0500
Started GET "/escrow-admin/foundation/foundation.accordion.self-d55abdcb0a7a29512be2f31f63d418cc8cc4505a0a3c71946d25484b0a0b3f4e.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:13 -0500
Started GET "/escrow-admin/foundation/foundation.equalizer.self-7aa743bf4660deb2fb2f601c112806a1703c430067531da3f41e4afffe19fee9.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:14 -0500
Started GET "/escrow-admin/foundation/foundation.joyride.self-0a5271728699423f583dd5b3b8a11bfe0dc9fb5044446bcf3218ef8ca906a82d.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:14 -0500
Started GET "/escrow-admin/foundation/foundation.offcanvas.self-75bffd0c7f4f0d2992ab95f0cc6959282ebb5807da70123d40c01d76e230ec88.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:14 -0500
Started GET "/escrow-admin/foundation/foundation.orbit.self-f8d30eb1717c874db26723f9e07901ec0a325d59263f1404ee83a616bb597ad2.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:14 -0500
Started GET "/escrow-admin/foundation/foundation.slider.self-8911a7352cb577b6b7973b0734d57d2b624c79286558ffa36fcac0c29b2d0bee.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:14 -0500
Started GET "/escrow-admin/foundation/foundation.tab.self-9bf6791513d1b20e213bb1aee3df0bc17128c7e18421258dc68a2a4ccabe1647.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:14 -0500
Started GET "/escrow-admin/foundation/foundation.tooltip.self-834156796c253580629cfffc720bdc3d191b1e5a5a6ddbc1102ecd08c876516c.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:14 -0500
Started GET "/escrow-admin/escrow_sessions.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:14 -0500
Started GET "/escrow-admin/svn_repos.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:14 -0500
Started GET "/escrow-admin/welcome.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:14 -0500
Started GET "/escrow-admin/foundation/foundation.abide.self-f8b56c707a79139807305a5f7efc2aaa0848f0c677abcc056496f507e0192b79.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:14 -0500
Started GET "/escrow-admin/foundation/foundation.clearing.self-54610737b435a97590fcb176848c3c7a44c4d55d369894260fa7c28c97a70a23.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:14 -0500
Started GET "/escrow-admin/foundation/foundation.dropdown.self-c9ee29909e266373e5e814a73fc6ea062245ddd29466d35d232448f73350d78a.js?body=1" for 127.0.0.1 at 2015-06-12 12:02:14 -0500
Started GET "/escrow-admin/escrow_sessions" for 127.0.0.1 at 2015-06-12 12:02:22 -0500
Started GET "/escrow-admin/escrow_sessions" for 127.0.0.1 at 2015-06-12 12:02:22 -0500
class EscrowSessionsController < ApplicationController
before_action :set_escrow_session, only: [:show, :edit, :update, :destroy]
# GET /escrow_sessions
# GET /escrow_sessions.json
def index
@escrow_sessions = EscrowSession.all
@svn_repos = SvnRepo.all
end
# GET /escrow_sessions/1
# GET /escrow_sessions/1.json
def show
end
# GET /escrow_sessions/new
def new
@escrow_session = EscrowSession.new
@svn_repo_engine = SvnRepoEngine.new
@svn_repo_engine.populate_svn_repos
@svn_repos = SvnRepo.all
end
# GET /escrow_sessions/1/edit
def edit
end
# POST /escrow_sessions
# POST /escrow_sessions.json
def create
@escrow_session = EscrowSessions.create(escrow_session_params)
@svn_repos = SvnRepo.find(params[:svn_repo_ids])
@escrow_session.svn_repos << @svn_repos
respond_to do |format|
if @escrow_session.save
format.html { redirect_to root_path, notice: 'Escrow session was successfully created.' }
format.json { render :show, status: :created, location: @escrow_session }
else
format.html { render :new }
format.json { render json: @escrow_session.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /escrow_sessions/1
# PATCH/PUT /escrow_sessions/1.json
def update
respond_to do |format|
if @escrow_session.update(escrow_session_params)
format.html { redirect_to root_path, notice: 'Escrow session was successfully updated.' }
format.json { render :show, status: :ok, location: @escrow_session }
else
format.html { render :edit }
format.json { render json: @escrow_session.errors, status: :unprocessable_entity }
end
end
end
# DELETE /escrow_sessions/1
# DELETE /escrow_sessions/1.json
def destroy
@escrow_session.destroy
respond_to do |format|
format.html { redirect_to root_url, notice: 'Escrow session was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_escrow_session
@escrow_session = EscrowSession.find(params[:id])
end
def set_svn_urls
@svn_urls = `svn ls #{SVN_URL} --username=#{SVN_USER} --password=#{SVN_PASSWORD}`.split("\n").map{ |e| "#{SVN_URL}/#{e}" }
end
def set_svn_users
@svn_details = `svn ls --verbose #{SVN_URL} --username=#{SVN_USER} --password=#{SVN_PASSWORD}`
@svn_users = @svn_details.split("\n").map {|e| e.gsub(/\s+/, " ").split(" ")[1]}
end
def set_svn_dates
@svn_details = `svn ls --verbose #{SVN_URL} --username=#{SVN_USER} --password=#{SVN_PASSWORD}`
@svn_dates = @svn_details.split("\n").map {|e| e.gsub(/\s+/, " ").split(" ")[2..4].join(" ")}
end
# Never trust parameters from the scary internet, only allow the white list through.
def escrow_session_params
params.require(:escrow_session).permit(:name, :opened_at, :user_id, :closed_at, :archive_id, :svn_repo_ids)
end
end
Rails.application.routes.draw do
scope 'escrow-admin/' do
resources :svn_repos
resources :escrow_sessions
resources :archives
# devise_for :users, controllers: {
# sessions: 'users/sessions'
# }
get 'welcome/index'
root 'welcome#index'
end
end
accessing any resource other than the root url, I see this in the browser:
(function() {
}).call(this);
class WelcomeController < ApplicationController
def index
@escrow_sessions = EscrowSession.unarchived
@svn_repo_engine = SvnRepoEngine.new
@svn_repo_engine.populate_svn_repos
@svn_repos = SvnRepo.all
@archives = Archive.all
@create_escrow_prompt = @escrow_sessions.size.zero? ? "create Escrow Session" : "create another Escrow Session"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment