Skip to content

Instantly share code, notes, and snippets.

Sebastian buk

Block or report user

Report or block buk

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:339233
def validate
errors.add(:email, "must be valid.") unless email.include? ("@")
if screen_name.include("")
errors.add(:screen_name, "cannot include spaces.")
end
end
View gist:340549
def logout
User.logout!(session,cookies)
flash[:notice] = "Danke und Auf Wiedersehen!"
redirect_to :action => "index", :controller => "site"
end
@buk
buk / .htaccess
Created Dec 12, 2010
A .htaccess file to point a subdomain to a folder
View .htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} ^[www\.]*blog.domain.de [NC]
RewriteCond %{REQUEST_URI} !^/blog/.*
RewriteRule ^(.*) /blog/$1 [L]
View reports_controller.rb
class ReportsController < ApplicationController
def index
@reports = Report.all
end
def show
@report = Report.find(params[:id])
end
def new
We couldn’t find that file to show.
View reports_controller.rb
def index
#@reports = Report.all
@technician.reports
end
View reports_controller.rb
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 Apr 14, 2011
technician.rb und report.rb
View gist:920018
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 Apr 14, 2011
_form.html.erb
View gist:920039
<%= 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 Apr 28, 2011
rails g migration AddCustomerAppointmentToReport
View gist:947356
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
You can’t perform that action at this time.