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
question controller | |
def create | |
Question.create(params[:question]); | |
end | |
question new view | |
1 <h1>Question Form</h1> | |
2 | |
3 <%= form_for @question, url: {action: "create"} do |f| %> |
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 create | |
33 Question.create(question_params); | |
34 # Question.create(:title => params[:question][:title], | |
35 # :summary => params[:question][:summary], | |
36 # :subject_id => params[:question][:subject]) | |
37 end | |
38 def question_params | |
39 params.require(:question).permit(:title,:summary,:subject_id) | |
40 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
controller | |
def create | |
32 params[:question][:subjects].delete_if { |n| n == "" } | |
33 Question.create(:title => params[:question][:title], | |
34 :summary => params[:question][:summary], | |
35 :subject_id => params[:question][:subjects]) | |
36 end | |
model | |
1 class Question < ActiveRecord::Base |
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
Subject.joins(:questions).where(:questions => {:id => 3}) // to search questionS_subjects join table for triedto |
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
1 class OffersController < ApplicationController | |
2 before_action :authorize_user | |
3 def show | |
4 @validOffer = Offer.exists?(params[:id]); | |
5 puts @validOffer | |
6 if @validOffer | |
7 @offers = Offer.where(:question_id => params[:question_id]); | |
8 else | |
9 redirect_to root_path | |
10 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
routers.js | |
--- | |
import Ember from 'ember'; | |
var Router = Ember.Router.extend({ | |
location: GrowlogWebENV.locationType | |
}); | |
Router.map(function() { | |
this.route('login'); |
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
app/index.html | |
--- | |
app/initiliazers/application.js | |
--- | |
import Ember from 'ember'; | |
import Base from 'simple-auth/authenticators/base'; | |
var CustomAuthenticator = Base.extend({ |
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
createRecord: function(store, type, record) { | |
var data = {}; | |
var serializer = store.serializerFor(type.typeKey); | |
serializer.serializeIntoHash(data, type, record, { includeId: true }); | |
if (record.get('isNew') && type.typeKey == 'room' && data.room.operation_id) | |
{ | |
var op_id = data.room.operation_id; | |
delete data.room.operation_id; | |
return this.ajax(this.buildURL('operations/' + op_id + '/room', null, record), "POST", { data: data }); |
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
import Ember from 'ember'; | |
export | |
default Ember.View.extend({ | |
templateName: 'driver', | |
didInsertElement: function() { | |
this._super(); | |
var chart = c3.generate({ | |
bindto: '#chart', | |
data: { |
OlderNewer