Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:

Juguang XIAO between40and2

:octocat:
View GitHub Profile
@between40and2
between40and2 / rails-initializers.md
Last active Aug 29, 2015
This is enlightened by ...
View rails-initializers.md

Rails Initializers

Be sure to restart your server when you modify this file.

backtrace_silencers.rb

You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.

View rails-init-process.md

root.rb

application.rb

Here is note in that file

# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
@between40and2
between40and2 / rails-console-migration-cheatsheet.md
Last active Aug 29, 2015
You can do a lot of things in rails console. Here we just tip on migration part.
View rails-console-migration-cheatsheet.md

How database/table related info

Account.table_name
Account.columns.collect {|x| x.name}

Change table structure

Even you can do rails g migration in cli, which is also persisted to share. Here is a quick and dirty way.

@between40and2
between40and2 / rails-plugin-and-scaffold-css.md
Last active Aug 29, 2015
Rails Plugin and scafford css
View rails-plugin-and-scaffold-css.md

Rails Plugin

With my experience with Rails 4.0.5 so far, to my own naivety, I found that the error message displayed in form is different from the normal Rails app. The root cause is that 'scaffold.css' is not included.

Code generated by scaffold

<div class="field">
 <%= f.label :password %><br>
 <%= f.password_field :password %>
@between40and2
between40and2 / rails-css-js-seamless-integration
Last active Aug 29, 2015
How to make UI+JS staff working with Rails projects seamlessly
View rails-css-js-seamless-integration
make design-work (css+js) a Rails mountable plugin.
- Install Rails on designer's machine.
- create a Rails mountable plugin, and put it in svn.
- let designers edit assets files, while browsing Rails running server.
understand sprocket and its limitations.
- expose all that are 'required' files into one big file to output.
View date time format: ISO_8601
I am developing for iOS and RoR. For date time issue, I feel lucky, since both works with ISO 8601.
By default, Rails 4 returns ISO 8601 format as json output.
On iOS, you should have date format as @"yyyy-MM-dd'T'HH:mm:ssZZZ"
See http://developer.github.com/v3/ (search "ISO")
@between40and2
between40and2 / rails-how-to-customize-json
Created Dec 27, 2013
If you are not satisfied with default to_json implementation of ActiveRecord. Here is the way out.
View rails-how-to-customize-json
Customizing a model object's JSON representation, first of all, is a business of ActiveRecord::Serialization. You will look at ActiveModel::Serializers::JSON class
https://github.com/rails/rails/blob/master/activemodel/lib/active_model/serializers/json.rb
and then will come back to ActiveModel::Serialization class
https://github.com/rails/rails/blob/master/activemodel/lib/active_model/serialization.rb
View rails-routes-in-depth
Do you know, you can access your own rails website on /rails/info/routes , under development environment?
The working house is shown below.
https://github.com/rails/rails/blob/master/railties/lib/rails/info_controller.rb
In turn, ActionDispatch::Routing::RoutesInspector is the real hero. Linked below.
https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/routing/inspector.rb
@between40and2
between40and2 / JXUIStory_id_creation__UINC
Last active Dec 29, 2015
JXUIStory_id_creation__UINC
View JXUIStory_id_creation__UINC
UIStory needs a Procedure to guide it, and story listens to Procedure's events of proceed and complete .
It is UIStory to expose proceedNext method for client to call. While UI will have "next" button to proceed the procedure, too.
UIStory has a JXUIVCFactory_ProcedureStep .
VCFactory will createVC, setObject:intoVC, and getObject:fromVC, according to step.
Since the kinds of steps are currently limited, the VC types to be used are limited too, therefore manually manageable.
JXModel_ProcedureStep_ObjectPart_Attribute --- JXUITVDSD_NSArray_Selection (or JXUITVDSD_NSArray_Selection__allowsAddSimpleTextOptions)