Skip to content

Instantly share code, notes, and snippets.

View dennermiranda's full-sized avatar

Dener Miranda dennermiranda

View GitHub Profile
dener@dener-VGN-NW210AE:~/rails$ rvm requirements
Requirements for Linux ( DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04 LTS" )
NOTE: 'ruby' represents Matz's Ruby Interpreter (MRI) (1.8.X, 1.9.X)
This is the *original* / standard Ruby Language Interpreter
'ree' represents Ruby Enterprise Edition
dener@dener-VGN-NW210AE:~/rails$ rails new teste
create
create README.rdoc
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/assets/images/rails.png
create app/assets/javascripts/application.js
@dennermiranda
dennermiranda / function.c
Created September 7, 2011 20:12
Trabalho prog
#include <stdio.h>
#include <stdlib.h>
struct item_agenda
{
char *nome;
int idade;
char sexo;
float ira;
char fone[10];
def create
@post = Post.new(params[:post])
respond_to do |format|
if @post.save
format.html { redirect_to(@post, :notice => 'Post was successfully created.') }
format.xml { render :xml => @post, :status => :created, :location => @post }
else
format.html { render :action => "new" }
format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
def create
@topic = Topic.new(params[:topic])
respond_to do |format|
if @topic.save
format.html { redirect_to(@topic, :notice => 'Topic was successfully created.') }
format.xml { render :xml => @topic, :status => :created, :location => @topic }
else
format.html { render :action => "new" }
format.xml { render :xml => @topic.errors, :status => :unprocessable_entity }
class GradesController < ApplicationController
#load_and_authorize_resource
before_filter :authenticate_user!
def aluno
@aluno =Aluno.find(current_user.associable_id)
@pessoa = Pessoa.find(@aluno.pessoa_id)
@aluno_diario = AlunoDiario.where(:aluno_id => @aluno.id).includes(:diario => [:curso, :disciplina])
end
def professor
class GradesController < ApplicationController
#load_and_authorize_resource
before_filter :authenticate_user!
def aluno
@aluno =Aluno.find(current_user.associable_id)
@pessoa = Pessoa.find(@aluno.pessoa_id)
@aluno_diario = AlunoDiario.where(:aluno_id => @aluno.id).to_a
@diario = []
# @aluno_diario = AlunoDiario.all(:joins => 'SELECT * FROM aluno_diarios diarios LEFT OUTER JOIN disciplinas ON disciplinas.id = diarios.disciplina_id WHERE diarios.id = aluno_diarios.diario_id and aluno_id = 2')
SystemStackError in GradesController#aluno
stack level too deep
Rails.root: /home/dener/rails_projects/webgrades
Application Trace | Framework Trace | Full Trace
activerecord (3.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:234:in `current_connection_id'
activerecord (3.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:96:in `connection'
activerecord (3.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:318:in `retrieve_connection'
activerecord (3.0.0) lib/active_record/connection_adapters/abstract/connection_specification.rb:97:in `retrieve_connection'
activerecord (3.0.0) lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in `connection'
class GradesController < ApplicationController
#load_and_authorize_resource
def aluno
@aluno =Aluno.find(current_user.id)
@aluno_diario = AlunoDiario.find(:aluno_id == aluno.id)
#@curso = Curso.all
#@disciplina = Disciplina.all
end
end
NameError in GradesController#aluno
uninitialized constant Grade
Rails.root: /home/dener/rails_projects/webgrades
Application Trace | Framework Trace | Full Trace
activesupport (3.0.0) lib/active_support/inflector/methods.rb:113:in `constantize'
activesupport (3.0.0) lib/active_support/inflector/methods.rb:112:in `each'
activesupport (3.0.0) lib/active_support/inflector/methods.rb:112:in `constantize'
activesupport (3.0.0) lib/active_support/core_ext/string/inflections.rb:43:in `constantize'
cancan (1.4.0) lib/cancan/controller_resource.rb:102:in `resource_class'