Skip to content

Instantly share code, notes, and snippets.

Controller:
class ModlessController < ApplicationController
def model_params
params.require(:model).permit(:tag_list)
end
end
Model:
def update
@model.update(model_params)
respond_with(@model)
end
def model_params
params.require(:model).permit( :name, :tag_list, :tags )
end
end
class ModelsController < ApplicationController
before_action :set_model, only: [:show, :edit, :update, :destroy]
respond_to :html, :json
def update
Rails.logger.info "=============="
Rails.logger.info params[:model][:tags]
Rails.logger.info params[:model][:tag_list]
Rails.logger.info "=============="
@model.update(model_params)
params.require(:modle).permit(
:name, :user_id,:image,
:tag_list, :tags, :description
)
COLOR_LIGHT_RED=$(tput sgr0 && tput bold && tput setaf 1)
COLOR_LIGHT_CYAN=$(tput sgr0 && tput bold && tput setaf 6)
COLOR_RESET=$(tput sgr0)
say -v ? | while read line; do
voice=`echo $line | awk '{ print $1 }'`
phrase=`echo $line | sed -E 's/^.+# //'`
echo "${COLOR_LIGHT_RED}say -v ${COLOR_LIGHT_CYAN}${voice}${COLOR_RESET} $phrase"
say -v $voice $phrase
done
<ReactCSSTransitionGroup transitionName="fadeIn">
{this.state.loading && <Loading key={0} />}
{this.state.error &&
<div className="alert alert-block alert-danger" key={1}>
Error: { messages[ this.state.error ] }
</div>}
{this.state.success &&
<div className="alert alert-block alert-success" key={2}>
Success!
</div>}
// Top level component
<component>
<UserModal isOpen={this.state.whatever} />
</component>
// UserModal
{
render:function() {
return <BaseModal {...this.props}>
@AndrewRayCode
AndrewRayCode / gist:b4ac61b6d301e30d37e9
Last active August 29, 2015 14:17
Better React ClassSet
// Lets you call classSet with strings *and* objects
// Usage: classSet({a: true, b: false}, 'class1', null, 'class2'); class="a class1 class2"
function classSet() {
var classes = [],
arg, x, key;
for( x = 0; x < arguments.length; x++ ) {
arg = arguments[ x ];
if( typeof arg === 'object' ) {
componentDidMount: function() {
UserStore.on( 'change', this.onStoreChange );
},
componentWillUnmount: function() {
UserStore.off( 'change', this.onStoreChange );
@AndrewRayCode
AndrewRayCode / gist:caef6fc3991823fced0f
Last active August 29, 2015 14:20
NodeJS convert CSV to JSON object with headers
var csv = require('csv');
csv.parse(fs.readFileSync('./csv_with_headers.csv'), function(err, data) {
// Store the headers row
var headers = data[0];
// Remove the headers row
data.shift();
var objects = _.map(data, function(csvRow) {