This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'digest' #for password hasing | |
class User < ActiveRecord::Base | |
#It tells Ruby to create reader and writer methods for password. Because the password | |
#column doesn’t exist in your table anymore, a password method isn’t created automatically | |
#by Active Record. Still, you need a way to set the password before it’s encrypted, so you make | |
#your own attribute to use. This works like any model attribute, except that it isn’t persisted to | |
#the database when the model is saved. | |
attr_accessor :password |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DeviseCreateUsers < ActiveRecord::Migration | |
def change | |
create_table(:users) do |t| | |
## Database authenticatable | |
t.string :email, :null => false, :default => "" | |
t.string :encrypted_password, :null => false, :default => "" | |
## Rememberable | |
t.datetime :remember_created_at |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This is my file altered... the one that works for me | |
class DeviseCreateUsers < ActiveRecord::Migration | |
def change | |
create_table(:users) do |t| | |
## Database authenticatable | |
t.string :email, :null => false, :default => "" | |
t.string :encrypted_password, :null => false, :default => "" | |
## Rememberable | |
t.datetime :remember_created_at |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CommentsController < ApplicationController | |
before_filter :load_article, :except => :destroy | |
before_filter :authenticate, :only => :destroy | |
def create | |
@comment = @article.comments.new(comment_params) | |
if @comment.save | |
redirect_to @article, :notice => 'Thanks for your comment' | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("<%= escape_javascript render(:file => 'comments/new.html.erb') %>").insertAfter('#comments'); | |
$('#new_comment_link').hide(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<a href="path..."> | |
<i class="icon-home" icon-large="2x"></i> | |
Home | |
</a> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Product < ActiveRecord::Base | |
require 'roo' | |
validates_presence_of :price | |
def self.to_csv(options = {}) | |
CSV.generate(options) do |csv| | |
csv << column_names | |
all.each do |product| | |
csv << product.attributes.values_at(*column_names) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/ruby | |
#all those informations are fictive | |
students = {:VILC22579307 => "VILLENEUVE-ASSE, CINDY", | |
:NDIJ19129106 => "NDIAYE YEND, JEAN-LOUIS RUDY", | |
:JEAJ03108909 => "JEAN-BAPTISTE, JOSEPH-RAYMOND MARC", | |
:ELME29089109 => "EL MOUTARAJJI EL ALA, ELIAS", | |
:TRED01039200 => "TREMBLAY, DENIS MARC-ANDRE PIERRE", | |
:AUCM28579305 => "AUCLAIR-JULIEN, MARIE-ISABELLE"} | |
students.count |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "afficher le mois de naissance explicitement" | |
students.each { |k, value| | |
mon_mois = le_mois k.slice(6,2).to_i | |
puts "etudiant #{k} est ne en #{mon_mois} " | |
} | |
#return a month name | |
def le_mois number | |
number = number > 50 ? number-50 : number | |
case number |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="image-row"> | |
<div class="image-set"> | |
<% Image.all.each do |i| %> | |
<a class="without-caption image-link" data-lightbox="image-1" rel="shadowbox" href="<%=i.image.to_s %>" title="<%= i.caption %>"> | |
<%= image_tag i.image.url(:thumb) %> | |
</a> | |
<% end %> | |
</div> | |
</div> |
OlderNewer