Skip to content

Instantly share code, notes, and snippets.

View lbramos's full-sized avatar

Luis Bivar Ramos lbramos

View GitHub Profile
# if you create subfolders inside assets/images you will need to add them to the path
# just put this code inside application.rb
Dir.glob("#{Rails.root}/app/assets/images/**/").each do |path|
config.assets.paths << path
end
# thanks to @depa at http://stackoverflow.com/questions/21502608/rails-4-asset-pipeline-image-subdirectories
@lbramos
lbramos / ResponsiveBackgroundFullImage.css
Last active August 29, 2015 14:16
Background Full Image - Responsive (CSS)
/* Solution to make a responsive background full image
courtesy of http://sixrevisions.com/css/responsive-background-image/ */
body {
/* Location of the image */
background-image: url("Concierge.jpg");
/* Background image is centered vertically and horizontally at all times */
background-position: center center;
/* Background image doesn't tile */
@lbramos
lbramos / BackButton
Created February 1, 2015 17:32
Browser Back Button Behavior
// I needed a way to hijack the browser back button on a Ruby on Rails app,
// so users don't make a mistake thinking that they're editing a record instead of creating a new one
// Thanks to thecssninja.com site :)
(function(window, location) {
history.replaceState(null, document.title, location.pathname+"#!/nobackbutton");
history.pushState(null, document.title, location.pathname);
window.addEventListener("popstate", function() {
alert('To go back or edit the record, please use the buttons below!');
if(location.hash === "#!/nobackbutton") {
@lbramos
lbramos / validations
Last active August 29, 2015 14:13
Validate fields depending on the another field value
#problem: validate field2 and field3 depending on value of field1
validates :field1, presence: true
validates :field2, presence: true, :if => Proc.new {|o| o.field1 == "Yes" }
validates :field3, presence: true, :if => Proc.new {|p| p.field1 == "No" }