This file contains 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
<!-- Someone can visit http://localhost:3000/profiles/my-permalink and this page will display (this part is working fine!). --> | |
<h2>Edit your profile, <%= @user.first_name %>.</h2> | |
<%= form_for @user, :html => { :class => "form-horizontal"} do |f| %> | |
<%= f.label :first_name, "Your First Name" %> | |
<%= f.text_field :first_name %> | |
<%= f.submit "Update Profile" %> | |
<% end %> |
This file contains 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 UserSession < Authlogic::Session::Base | |
def remember_me_for | |
3.months | |
end | |
end |
This file contains 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
var andrewpank = array( | |
"watermelon", | |
"pinapple", | |
"strawberrires" | |
); |
This file contains 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
What I'm trying to achieve? | |
I want to have a left tooltip (tooltip-left) for the 2 results which display on the left hand side, and a right tooltip (tooltip-right) for the other 2 results which display on the right. |
This file contains 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
# URL Visiting: example.com/posts?search=My+search+text&m=aug&y=13 | |
search_sql = "MATCH (title,tags) AGAINST ('query_string('search')' IN BOOLEAN MODE)" | |
#=> MATCH (title,tags) AGAINST ('My search text' IN BOOLEAN MODE) | |
month_sql = "created_at LIKE ('%-#{return_month_number(query_string('m'))}-%')" | |
#=> created_at LIKE ('%-08-%') | |
year_sql = "MATCH (created_at) AGAINST ('#{(Time.now.strftime('%Y')[0..1]).to_s + query_string('y').to_s}' IN BOOLEAN MODE)" | |
#=> MATCH (created_at) AGAINST ('2013') | |
Post.where( |
This file contains 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 AvatarValidator < ActiveModel::Validator | |
def validate(record) | |
unless gravatar_exists? | |
return record.errors[:avatar] << "No display picture could be found on Gravatar using #{record.avatar}." | |
end | |
end | |
end | |
class Comment < ActiveRecord::Base | |
has_one :post |
This file contains 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 Comment < ActiveModel::Base | |
validate :valid_url?, :allow_blank => true | |
def valid_url? | |
if (self.website).start_with?("http://", "https://") and (self.website).end_with?(".*") | |
return true | |
elsif (self.website).end_with?(".*") | |
return true | |
self.website = "http://#{self.website}" | |
else | |
return self.errors[:website] << "The website you entered (#{self.website}) is invalid. Please try again." |
This file contains 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
var commentForm = $("form#newComment"); | |
commentForm.submit(function() { | |
event.preventDefault(); | |
$("#commentName").attr("disabled", true); | |
$("#commentGravatar").attr("disabled", true); | |
$("#commentWebsite").attr("disabled", true); | |
$("#commentBody").attr("disabled", true); | |
$("#createComment").attr("disabled", true); |
This file contains 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
$.ajax({ | |
// blah-blah-blah, | |
success: outputSomething | |
}); | |
function outputSomething(data) { | |
$.each(data.errors, function(field, message) { | |
alert(field); // alert("body"), alert ("name") | |
}) | |
} |
This file contains 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
# Active Record lets you do things like: | |
Post.find(3).title | |
#=> "Hello, world!" | |
# Cool. So my question is, how exactly do you setup a class that allows the | |
# programmer to use there own keyword? My use case: | |
def get(type, id) |
OlderNewer