<% form_for(@vote) do |f| %>
<%= f.error_messages %>
<% @survey_options.each do |survey_option| %>
<table>
<tr>
<td>
<%= f.radio_button 'survey_option_id', survey_option.id %>
<%= f.label(:survey_option, survey_option.name) %>
</td>
</tr>
</table>
<% end %>
<p>
<%= f.submit 'Create' %>
</p>
<% end %>
Showing posts with label RubyonRails. Show all posts
Showing posts with label RubyonRails. Show all posts
hidden_field
Posted by
Lon
on Sunday, July 26, 2009
Labels:
RubyonRails
/
Comments: (0)
<%= f.hidden_field :survey_title_id, :value => @survey_title.id %>
Namespace Tutorial
Posted by
Lon
on Saturday, July 25, 2009
Labels:
RubyonRails
/
Comments: (1)
ruby script/generate scaffold SurveyOption name:string disable:boolean survey_title:references
rake db:migrate
ruby script/generate controller Admin::Survey_Options
map.namespace :admin do |admin|
admin.resources :survey_options
end
copy all codes in controller/survey_options_controller.rb to controller/admin/survey_options_controller.rb
change redirect_to(@survey_option) to redirect_to([:admin, @survey_option]) and redirect_to(survey_option_url) to redirect_to(admin_survey_options_url)
copy all files in views/survey_options to views/admin/survey_options
edit views/admin/survey_options/edit, index, new, show files.
http://railsforum.com/viewtopic.php?id=21742
http://www.akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-first-full-tutorial
rake db:migrate
ruby script/generate controller Admin::Survey_Options
map.namespace :admin do |admin|
admin.resources :survey_options
end
copy all codes in controller/survey_options_controller.rb to controller/admin/survey_options_controller.rb
change redirect_to(@survey_option) to redirect_to([:admin, @survey_option]) and redirect_to(survey_option_url) to redirect_to(admin_survey_options_url)
copy all files in views/survey_options to views/admin/survey_options
edit views/admin/survey_options/edit, index, new, show files.
http://railsforum.com/viewtopic.php?id=21742
http://www.akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-first-full-tutorial
Better than Bort - BaseApp
Posted by
Lon
on Tuesday, July 14, 2009
Labels:
RubyonRails
/
Comments: (0)
To use BaseApp read the tutorial below
- http://github.com/ariejan/baseapp/tree/master
- http://vladzloteanu.wordpress.com/2009/07/13/rails-startup-app-basecamp-user-authentication/
MySQL Socket
Posted by
Lon
Labels:
MySql,
RubyonRails
/
Comments: (0)
To find the correct path to mysql socket
- mysql_config --socket
Column Properties
Posted by
Lon
on Monday, June 15, 2009
Labels:
RubyonRails
/
Comments: (0)
String - shot character
Text - long string
Integer - no decimal
Boolean - true or false
Float - number with decimal
Date - calendar date
Text - long string
Integer - no decimal
Boolean - true or false
Float - number with decimal
Date - calendar date
Using Bort
Posted by
Lon
Labels:
RubyonRails
/
Comments: (0)
Download and extract Bort - http://github.com/fudgestudios/bort/tree/master
Configure
Command
Configure
- config/settings.yml
- config/database.yml
- db/migrate/bort_migration.rb
Command
- rake db:create
- rake db:migrate
Recaptcha
Posted by
Lon
on Friday, April 3, 2009
Labels:
Plugins,
Recaptcha,
RubyonRails
/
Comments: (0)
Model Validation
Posted by
Lon
on Monday, March 30, 2009
Labels:
ActiveRecord,
RubyonRails
/
Comments: (0)
Validation Helpers
- validates_acceptance_of
- validates_associated
- validates_confirmation_of
- validates_exclusion_of
- validates_format_of
- validates_inclusion_of
- validates_length_of
- validates_numericality_of
- validates_presence_of
- validates_uniqueness_of
- validates_each
- :allow_nil
- :allow_blank
- :message
- :on
How to get the user_id
Posted by
Lon
on Thursday, March 19, 2009
Labels:
HowTo,
RubyonRails
/
Comments: (0)
@comment.user = User.find(session[:user_id])
How to random select
Posted by
Lon
on Wednesday, March 18, 2009
Labels:
HowTo,
RubyonRails
/
Comments: (0)
@story = Story.find(:first, :order => 'RAND()')
Programming Best Practices
Posted by
Lon
on Tuesday, March 17, 2009
Labels:
RubyonRails
/
Comments: (0)
Active Record Methods and Options
Posted by
Lon
on Wednesday, March 11, 2009
Labels:
ActiveRecord,
RubyonRails
/
Comments: (0)
ActiveRecord Methods => Used in Controller
ActiveRecord Options => User in Model
ActiveRecord Options => User in Model
Routing _path and _url
Posted by
Lon
on Monday, March 9, 2009
Labels:
RubyonRails,
Tutorial
/
Comments: (0)
_path is used in Views
_url is used in Controller
_url is used in Controller
Basic Git Commands
Posted by
Lon
on Friday, March 6, 2009
Labels:
Desiremesh,
git,
RubyonRails,
Unfuddle
/
Comments: (0)
git clone git@desiremesh.unfuddle.com:desiremesh/newsgroup.git
git commit -a -m 'comments here'
git push
git commit -a -m 'comments here'
git push
Ruby on Rails Gems
Posted by
Lon
on Wednesday, March 4, 2009
Labels:
Gems,
RubyonRails
/
Comments: (0)
http://docs.rubygems.org/
http://gems.github.com
http://gems.github.com
Passenger for Ruby on Rails on Dreamhost
Posted by
Lon
Labels:
Deployment,
Dreamhost,
Passenger,
RubyonRails
/
Comments: (0)
Thinking Sphinx Tutorial with Delta Indexing
Posted by
Lon
Labels:
Plugins,
RubyonRails,
Tutorial
/
Comments: (0)
ruby script/plugin install git://github.com/freelancing-god/thinking-sphinx.git
ruby script/plugin install git://github.com/mislav/will_paginate.git # to use will_paginate
In Model
define_index do
indexes searchable_fields, :sortable => true # to sort the fields
set_property :delta => true # no need to run rake ts:index everytime there is a new data entry, but its really recommend to run rake ts:index everyhour or everyday
end
In Controller
def search
@string = Model.search params[:search], :page => params[:page], :per_page => no_of_page, :order => :sortable_fields
end
In View
<% for person in @Person %>
<%= person.name -%> <%= link_to "show", {:action => 'show', :id => person.id} -%>
<% end %>
<%= will_paginate @person %> # to activate pagination
Create boolean delta in model
ruby script/generate migration add_boolean_data
def self.up
add_column :model, :delta, :boolean, :default => false
end
rake db:migrate
Terminal Commands # run this command to activate delta indexing
rake ts:stop # ts or thinking_sphinx
rake ts:index
rake ts:start
Railscasts
Resources
ruby script/plugin install git://github.com/mislav/will_paginate.git # to use will_paginate
In Model
define_index do
indexes searchable_fields, :sortable => true # to sort the fields
set_property :delta => true # no need to run rake ts:index everytime there is a new data entry, but its really recommend to run rake ts:index everyhour or everyday
end
In Controller
def search
@string = Model.search params[:search], :page => params[:page], :per_page => no_of_page, :order => :sortable_fields
end
In View
<% for person in @Person %>
<%= person.name -%> <%= link_to "show", {:action => 'show', :id => person.id} -%>
<% end %>
<%= will_paginate @person %> # to activate pagination
Create boolean delta in model
ruby script/generate migration add_boolean_data
def self.up
add_column :model, :delta, :boolean, :default => false
end
rake db:migrate
Terminal Commands # run this command to activate delta indexing
rake ts:stop # ts or thinking_sphinx
rake ts:index
rake ts:start
Railscasts
Resources
Step by Step Guide in creating Project
Posted by
Lon
Labels:
RubyonRails
/
Comments: (0)
- Rails project_name
- Delete public/index
- Generate controller - Plural
- Generate model - Singular
- Setup database.yml
- Rake db:create then migrate
- Setup config/routes
- Setup controller
- Setup model
- Setup view
- index
- show
- new
- create
- edit
- update
- delete
- paperclip - photo attachment
- thinking_sphinx - full text search
- will_paginate - pagination
link_to syntax
Posted by
Lon
on Tuesday, March 3, 2009
Labels:
RubyonRails,
Syntax,
Tutorial
/
Comments: (1)
<%= link_to display_text, link, { option } %>
The three options specific to link_to (:confirm, :popup, and :method)
Others:
http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#M001565
The three options specific to link_to (:confirm, :popup, and :method)
link_to "Visit Other Site", "http://www.rubyonrails.org/", :confirm => "Are you sure?"
# => Visit Other Site
link_to "Help", { :action => "help" }, :popup => true
# => Help
link_to "View Image", @image, :popup => ['new_window_name', 'height=300,width=600']
# => View Image
link_to "Delete Image", @image, :confirm => "Are you sure?", :method => :delete
# => Delete Image
Others:
- link_to_if
- link_to_unless
- link_to_unless_current
- mail_to
- url_for
http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#M001565