An Intro for the WWU-Seminar User2User by Zweitag GmbH
What does the ruby do on the rail?
class Student
attr_accessor :name, :student_number, :semester
def initialize(name, student_number, semester)
@name = name
@student_number = student_number
@semester = semester
end
def getStudentCard
puts "#{@name} #{ @student_number}"
puts "Semester #{@semester}"
end
end
s = Student.new("Rob", 12345, 5)
s.getStudentCard
90,954
3,899,752,751
gem install my_very_cool_gem
class User < ActiveRecord::Base
has_secure_password
attr_accessible :email, :password, :phone_number
has_many :issues, dependent: :destroy
validates :email, presence: true, uniqueness: { case_sensetive: false },
length: { minimum: 6, maximum: 100 }
validates :password, presence: true, length: { minimum: 12 }
end
class UserController < ApplicationController
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
session[:user_id] = @user.id
redirect_to root_url, notice: "Thank's for registering"
else
render "new"
end
end
end
= form_for @user do |f|
- if @user.errors.any?
.error_messages
%h4 some errors occured
%ul
- @user.errors.full_messages.each do |message|
%li= message
.field
= f.label :email
= f.text_field :email
.field
= f.label :password
= f.password_field :password
.actions
= f.submit "Register"