Skip to content

Instantly share code, notes, and snippets.

def validate
errors.add(:email, "must be valid.") unless email.include? ("@")
if screen_name.include("")
errors.add(:screen_name, "cannot include spaces.")
end
end
def logout
User.logout!(session,cookies)
flash[:notice] = "Danke und Auf Wiedersehen!"
redirect_to :action => "index", :controller => "site"
end
@buk
buk / .htaccess
Created December 12, 2010 09:24
A .htaccess file to point a subdomain to a folder
RewriteEngine On
RewriteCond %{HTTP_HOST} ^[www\.]*blog.domain.de [NC]
RewriteCond %{REQUEST_URI} !^/blog/.*
RewriteRule ^(.*) /blog/$1 [L]
class ReportsController < ApplicationController
def index
@reports = Report.all
end
def show
@report = Report.find(params[:id])
end
def new
@buk
buk / gist:919961
Created April 14, 2011 17:16
Fehlermeldung beim Aufruf von http://127.0.0.1:3000/reports
We couldn’t find that file to show.
def index
#@reports = Report.all
@technician.reports
end
class ReportsController < ApplicationController
#before_filter :find_technician
def index
@reports = @technician.reports
end
def show
@report = @technician.report.find(params[:id])
end
@buk
buk / gist:920018
Created April 14, 2011 17:33
technician.rb und report.rb
class Technician < ActiveRecord::Base
attr_accessible :name, :email
has_many :@reports
end
class Report < ActiveRecord::Base
attr_accessible :technician_id, :title, :problem
belongs_to :technician
@buk
buk / gist:920039
Created April 14, 2011 17:45
_form.html.erb
<%= form_for @report do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :technician_id %><br />
<%= f.text_field :technician_id %>
</p>
<p>
<%= f.label :title %><br />
<%= f.text_field :title %>
</p>
@buk
buk / gist:947356
Created April 28, 2011 21:16
rails g migration AddCustomerAppointmentToReport
rails g migration AddCustomerAppointmentToReport customer_appointment:date
## migration file
class AddCustomerAppointmentToReport < ActiveRecord::Migration
def self.up
add_column :reports, :customer_appointment, :date
end
def self.down