Skip to content

Instantly share code, notes, and snippets.

View pinzonjulian's full-sized avatar
🤘

Julián Pinzón pinzonjulian

🤘
  • Melbourne, Australia
View GitHub Profile
@pinzonjulian
pinzonjulian / application.html.erb
Last active April 16, 2023 02:50
Application layout: full on spaghetti!
<!DOCTYPE html>
<html>
<head>
<!-- ... -->
</head>
<body>
<%= if current_user.signed_in? %>
<%= if current_page?(booking_rides_path) %>
<% end %>
class ExampleFormBuilder < ActionView::Helpers::FormBuilder
def error(method, error_text = nil, options = {})
return if errors_blank?(method) && error_text.blank?
text = if error_text
error_text
elsif object.errors.custom_messages_for(method)
object.errors.custom_messages_for(method).to_sentence
else
object.errors.full_messages_for(method).to_sentence
# UNEXPECTED BEHAVIOUR
class User < ApplicationRecord
has_many :client_posts,
class_name: Client::Post.name,
foreign_key: :user_id
end
class Client::Post < ApplicationRecord
# Note how the class_name is declared here
@pinzonjulian
pinzonjulian / admin_tangled_example.ruby
Created January 22, 2018 04:26
Organizing an app in Ruby on Rails
class OrdersController < ApplicationController
def new
# some cool code
end
def create
# some cool code
end