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
#!/usr/bin/env ruby | |
# Setup: | |
# 1) `gem install highline` | |
# 2) save this file to a local folder | |
# 3) rename the file to remove extension `mv kube_commands.rb kube_commands` | |
# 4) change permissions `chmod 755 kube_commands` | |
# 5) link to your /usr/local/bin `ln -s $PWD/kube_commands /usr/local/bin/` | |
# 6) in a new shell you should now be able to run `kube_commands` | |
# 7) add new commands and add to this gist |
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
Here is the code for the form, this is setup to look nice on a horizontal bootstrap form. Note the prompt:true, it puts a message in the select for the user to pick something, instead of forcing a default value. | |
<div class="form-group"> | |
<%= f.label "Choose a Contact", class: "col-xs-12 col-sm-2"%> | |
<div class="col-xs-3 col-sm-3"> | |
<%= f.collection_select :contact_id, @company.contacts, :id, :full_name, prompt: true, class: 'form-select' %> | |
</div> | |
</div> | |
How do you make this work? In the contact model add this: |
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
So at the top of the form helper you have something like this.. | |
this is your _form partial you are using for new and edit. | |
<%= form_for(@company, html: { class: 'form-horizontal' }) do |f| %> | |
.. | |
.. | |
Put some stuff in your form (this has some bootstrap 3 niceness) | |
.. | |
<div class="form-group"> | |
<%= f.label "Name", class: "col-sm-2 control-label"%> |
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 just keeps getting better! | |
This is a rails submit button for your form partial you use for new and edit. This will detect if it is a new record and use the right wording on your button and on your title. It also supports font awesome icons so you can have a cool checkmark circle on your button. | |
= button_tag(type: 'submit', class: "btn btn-default btn-float", title: f.object.new_record? ? "Create Drug" : "Update Drug") do | |
%i.fa.fa-check-circle.fa-fw | |
= f.object.new_record? ? "Create Drug" : "Update Drug" |
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 one was fun to figure out. | |
If you like to be DRY and use the same _form partial for your new and edit you run into a small problem if you set the title on the submit button. (title is used for text popping up when hovering over the element) | |
If you set title to "Create Reminder" then when your reminder new renders the form your title is right. But when you render the form from your edit page, the title is the same. | |
How to fix it? What to do? How about this: | |
<%= f.submit(class: "btn btn-default", title: f.object.new_record? ? "Create Reminder" : "Update Reminder") %> | |
Check to see if it is creating a new object, if so use the "Create Reminder" (true), if not use "Update Reminder" (false) |
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
In the HTML page: | |
<div id="alert" class="alert"> <-- This is div used in the popup | |
<p>Click to see Reminder</p> | |
</div> | |
In the script file: | |
var moveLeft = 0; | |
var moveDown = 0; | |
$('a .fa-reminder').hover(function(e) { <-- This is the element on page to show the hover on |
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
.collapse.navbar-collapse | |
%ul.nav.navbar-nav | |
%li= link_to "About", "#" | |
%li= link_to "Contact", "#" | |
%ul.nav.navbar-nav.navbar-right | |
- if user_signed_in? | |
%li= link_to "Prescriptions", prescriptions_path | |
%li= link_to "Drugs", drugs_path | |
%li.dropdown |
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
.btn-group | |
%button.btn.btn-primary.dropdown-toggle{type: "button", 'data-toggle'=> "dropdown"} | |
Action | |
%span.caret | |
%ul.dropdown-menu{role: "menu"} | |
%li= link_to "View", '#' | |
%li= link_to "Edit", '#' |