任何人都可以幫助解決這個問題後:軌重定向創建問題
在「創造」,將用戶重定向到URL:模型/ MODEL_ID(如柱/ 1),而不是我重定向到模型/ url_encoding_object (例如posts /。%23),並且在控制檯中有一個「406 Not Acceptable」消息。
通常,在創建時,控制檯的消息是「Processing PostsController#create(對於000.0.0.0,在2009-11-23 12:32:52)[POST]」,但是出現此錯誤消息是「Processing PostsController#create to#(對於000.0.0.0在2009-11-23 12:32:52)[POST]「
我見過austinfromboston的迴應,並嘗試了他的」老式但有效「的解決方案來解決類似的問題,但它不適合我。
任何幫助,將不勝感激
控制器代碼:
# POST /groups
# POST /groups.xml
def create
@group = Group.new(params[:group])
@group.category = params[:category]
@group.user = current_user
#here we add the current user to the membership collection of the group
@membership = @group.memberships.build(params[:membership])
@membership.group = @group
@membership.user = current_user
@membership.initiator = false
@membership.membership_status_id = 2
#and here we set the current_user as the owner of the group
@group_permission = @group.group_permissions.build(params[:group_permission])
@group_permission.membership = @membership
@group_permission.group_role = GroupRole.find_by_name('Owner')
unless params[:metro_area_id].blank?
@group.metro_area = MetroArea.find(params[:metro_area_id])
@group.state = (@group.metro_area && @group.metro_area.state) ?
@group.metro_area.state : nil
@group.country = @group.metro_area.country if (@group.metro_area &&
@group.metro_area.country)
else
@group.metro_area = @group.state = @group.country = nil
end
@group.tag_list = params[:tag_list] || ''
# unless @user.is_in_group?(@group)
# @user.memberships << @group
# end
respond_to do |format|
if @group.save
flash[:notice] = :group_was_successfully_created.l
format.html { redirect_to(group_path(@group.id)) }
else
format.html {
@metro_areas, @states = setup_metro_area_choices_for(@group)
if params[:metro_area_id]
@metro_area_id = params[:metro_area_id].to_i
@state_id = params[:state_id].to_i
@country_id = params[:country_id].to_i
end
render :action => "new"
}
end
end
end
解決:修復包括修訂到的form_tag,以及一個redirect_to的user_group_path(@ group.owner,@group) 感謝大家的幫助和指導。 – nml 2009-11-26 02:33:11