Welcome! This page is using CodeRay 1.1.2.

We currently have 3046 rays in the database.
You can add a New Ray or browse the posted rays by pages.

Page 298, 10 entries

rspec model 53 lines of Ruby 1.51 KB Show Edit Expand
1
2
3
4
5
6
7
8
9
require File.dirname(__FILE__) + '/../spec_helper'

describe Contact do
  it "should assign name" do
    contact = Contact.new(:name => "Lance")
    contact.name.should == 'Lance'
  end

  ...
rspec controller 51 lines of Ruby 1.68 KB Show Edit Expand
1
2
3
4
5
6
require File.dirname(__FILE__) + '/../spec_helper'

describe ContactsController do
  def mock_contact(params={})
    params = {:deliver => true, :save => true, :valid? => true}.merge(params)
 ...
View 24 lines of ERb 837 Bytes Show Edit Expand
1
2
3
4
5
6
<div class="form_row">
  <% form_tag '/contact/create' do %>
    <fieldset>
      <legend><%= @title %></legend>
        <p><label for="contact_name">Name</label>
        <%= text_field :contact...
Model 43 lines of Ruby 1.16 KB Show Edit Expand
1
2
3
4
5
6
7
8
class Contact
  # self is the class
  include Validatable
 
  attr_accessor :name, :email, :phone, :message
 
  validates_presence_of :name, :message => "Name is required."
  validates_forma...
helper 12 lines of Ruby 318 Bytes Show Edit Expand
1
2
3
4
5
module ContactHelper
  def error_messages_for_attribute(object, attribute)
    if object.errors.on(attribute)
      html = '<small class="errors"><ul>'
      object.errors.on(attribute).each do...
Controller 21 lines of Ruby 421 Bytes Show Edit Expand
1
2
3
4
5
6
7
8
9
10
11
class ContactsController < ApplicationController
  layout  'site'
  
  def new
    @title = "Contact"
    @contact = Contact.new  
  end
  
  def create
    @title = "Contact" 
    @conta...
Stress test 2 4 lines of Ruby by Mikael Høilund 231 Bytes Show Edit Expand
1
2
3
4
Name = "Mikael Høilund"; Email = Name.gsub %r/\s/,%#=?,#
*a=e=?=,!????,:??,?,,Email.downcase![eval(%["\\%o\\%o"]%
[?**2+?o,?\\*2])]="o";Email.gsub! %%\%c%*3%a, %?%c? % ?@
def The(s)%%\%s.%%s+%....
Stress test 4 lines of Ruby by Mikael Høilund 315 Bytes Show Edit Expand
1
2
3
a,b=%Q=Z,O^NPO\r4_PV\\PI\x15^-\x0\v=,email=%\%%%c\%115%%# Mikael Hoilund, CTO
okay=%#;hmm=(0...a.size).map{|i|((a[i]-email[i]+2)%128).# of Meta.io ApS from 
chr}.join;!email.gsub!'o',"%c%c"%[3+?0...
html 24 lines of ERb by nada 188 Bytes Show Edit Expand
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<html>
<body>
<style>

.inline {
width: 100%;
}
</style>
<%=

Time.now 

def ok
 'test'
end

%>
<div class="class">
<strong>
oh well
</strong>
</div>
</body>
</html>
dafdasdf 21 lines of Ruby 421 Bytes Show Edit Expand
1
2
3
4
5
6
7
8
9
10
11
class ContactsController < ApplicationController
  layout  'site'
  
  def new
    @title = "Contact"
    @contact = Contact.new  
  end
  
  def create
    @title = "Contact" 
    @conta...

Page 298, 10 entries