Projeto: Vermelho

logs of development
スポンサーサイト

一定期間更新がないため広告を表示しています

| - | | - | -
Rails3.1.1 + MongoDB + Devise
http://bugcloud.com/?p=1007


Ready-made install

mongoDBのcentos6.0へのインストール(yum)

rpmからならこちら
| Pg_Rails | 22:54 | comments(0) | trackbacks(0)
railsでa facebook style news feedを実現する方法
 http://stackoverflow.com/questions/2242173/how-do-i-create-a-facebook-style-news-feed-in-ruby-on-rails

You could do something as :

controller:

def index
    messages = Messages.all
    images = Images.all
    @feed = (messages + images).sort_by(&:created_at).reverse
end

view index.html.erb :

<%= render @feed %>
view _feed.html.erb :

<% if feed.is_a? Message %>
  <%= render "message", :locals => {:message => feed}%>
<% else %>
  <%= render "image", :locals => {:image => feed}%>
<% end %>
And add 2 partials _message.html.erb and _image.html.erb
| Pg_Rails | 22:49 | comments(0) | trackbacks(0)
uninitialized constant Rake::DSLが出たときの設定
Rails3.0.9, Ruby1.9.2, Rake0.9.2の環境で「uninitialized constant Rake::DSL」が出た場合の対処

 http://d.hatena.ne.jp/sea_mountain/touch/20110808/1312819492

| Pg_Rails | 00:16 | comments(1) | trackbacks(0)
[Rails]アソシエーションの関係にあるmodelをnestした場合の、createでエラーしたときのrenderの記述
やっと分かった(T_T).

controller:
def new @user = User.find(params[:user_id])
  @message = @user.messages.build
end

def create
  @user = User.find(params[:user_id])
  @message = @user.messages.new(params[:message])

  if @message.save
    flash[:notice] = 'Message saved'
    redirect_to user_url(@user)
  else
    render :action => "new" # Here is the problem I guess
  end
end
view:
<% form_for [@user, @message] do |f| %>
  <%= f.error_messages %>
  Name:<%= f.text_field :name %>
  Email:<%= f.text_field :email %>
  Message:<%= f.text_area :body, :rows => 3 %>
  <%= f.submit 'Send' %>
<% end %>
| Pg_Rails | 23:28 | comments(0) | trackbacks(0)
cucumber: featureファイルの生成
$ rails g cucumber:feature models
       exist  features/step_definitions
      create  features/manage_models.feature
      create  features/step_definitions/models_steps.rb
        gsub  features/support/paths.rb

| Pg_Rails | 01:07 | comments(1) | trackbacks(0)
PROFILE
CATEGORIES
LINKS
CALENDAR
S M T W T F S
      1
2345678
9101112131415
16171819202122
23242526272829
3031     
<< December 2018 >>
SELECTED ENTRIES
ARCHIVES
モバイル
qrcode
SPONSORED LINKS