我在我的表格中使用了邪恶宝石。事情是,当用户上传照片,他们可以看到在同一页的<代码>..../步骤/图片。在图片页面,用户可以销毁图片。当用户点击时,我想让他们重定向到步骤/图片页面,但无论我尝试什么,我都得到错误。船和图片关联,但不嵌套路线。
这是我的图片控制器#destroy
动作;
def摧毁
@picture = @boat.pictures.find(params[:id])
if @picture.destroy
######SOMETHING GOES HERE#########
flash[:notice] = "Successfully destroyed picture."
else
render json: { message: @picture.errors.full_messages.join(',') }
end
结束
#boat_steps
控制器;
class BoatStepsController < ApplicationController
include Wicked::Wizard
before_action :logged_in_user
steps :model, :pricing, :description, :features, :picture
def show
@boat = current_user.boats.last
case step
when :picture
@picture = @boat.pictures.new
@pictures = @boat.pictures.all
end
render_wizard
end
def update
@boat = current_user.boats.last
@boat.update(boat_params)
case step
when :picture
@picture.update(picture_params)
end
render_wizard @boat
end
private
def finish_wizard_path
new_boat_picture_path(@boat, @picture)
end
def boat_params
params.require(:boat).permit(......)
end
def picture_params
params.require(:picture).permit(......)
end
end
编辑1:
>rake routes
Prefix Verb URI Pattern Controller#Action
update_years GET /boats/update_years(.:format) boats#update_years
update_models GET /boats/update_models(.:format) boats#update_models
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PATCH /users/:id(.:format) users#update
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
boat_pictures GET /boats/:boat_id/pictures(.:format) pictures#index
POST /boats/:boat_id/pictures(.:format) pictures#create
new_boat_picture GET /boats/:boat_id/pictures/new(.:format) pictures#new
edit_boat_picture GET /boats/:boat_id/pictures/:id/edit(.:format) pictures#edit
boat_picture GET /boats/:boat_id/pictures/:id(.:format) pictures#show
PATCH /boats/:boat_id/pictures/:id(.:format) pictures#update
PUT /boats/:boat_id/pictures/:id(.:format) pictures#update
DELETE /boats/:boat_id/pictures/:id(.:format) pictures#destroy
boats GET /boats(.:format) boats#index
POST /boats(.:format) boats#create
new_boat GET /boats/new(.:format) boats#new
edit_boat GET /boats/:id/edit(.:format) boats#edit
boat GET /boats/:id(.:format) boats#show
PATCH /boats/:id(.:format) boats#update
PUT /boats/:id(.:format) boats#update
boat_steps GET /boat_steps(.:format) boat_steps#index
POST /boat_steps(.:format) boat_steps#create
new_boat_step GET /boat_steps/new(.:format) boat_steps#new
edit_boat_step GET /boat_steps/:id/edit(.:format) boat_steps#edit
boat_step GET /boat_steps/:id(.:format) boat_steps#show
PATCH /boat_steps/:id(.:format) boat_steps#update
PUT /boat_steps/:id(.:format) boat_steps#update
DELETE /boat_steps/:id(.:format) boat_steps#destroy
password_resets_new GET /password_resets/new(.:format) password_resets#new
password_resets_edit GET /password_resets/edit(.:format) password_resets#edit
profiles_edit GET /profiles/edit(.:format) profiles#edit
sessions_new GET /sessions/new(.:format) sessions#new
root GET / main#home
help GET /help(.:format) main#help
about GET /about(.:format) main#about
contact GET /contact(.:format) main#contact
signup GET /signup(.:format) users#new
login GET /login(.:format) sessions#new
POST /login(.:format) sessions#create
logout DELETE /logout(.:format) sessions#destroy
edit_account_activation GET /account_activations/:id/edit(.:format) account_activations#edit
password_resets POST /password_resets(.:format) password_resets#create
new_password_reset GET /password_resets/new(.:format) password_resets#new
edit_password_reset GET /password_resets/:id/edit(.:format) password_resets#edit
password_reset PATCH /password_resets/:id(.:format) password_resets#update
PUT /password_resets/:id(.:format) password_resets#update
编辑:
船步控制器
class BoatStepsController < ApplicationController
include Wicked::Wizard
before_action :logged_in_user
steps :model, :pricing, :description, :features, :picture
def show
@boat = current_user.boats.last
case step
when :picture
@picture = @boat.pictures.new
@pictures = @boat.pictures.all
end
render_wizard
end
def update
@boat = current_user.boats.last
@boat.update(boat_params)
case step
when :picture
@picture.update(picture_params)
end
render_wizard @boat
end
private
def finish_wizard_path
new_boat_picture_path(@boat, @picture)
end
def boat_params
params.require(:boat).permit(:brand, :year, :model, :captained, :boat_type, :daily_price, :boat_length, :listing_tagline, :listing_description, :boat_category, :hull_material, :mast_material, :capacity, :sleeping_capacity, :private_staterooms, :fuel_type, :engine_horsepower, :fuel_capacity, :fuel_consumption, :draft)
end
def picture_params
params.require(:picture).permit(:name, :boat_id, :image)
end
end
在wicked wizards上,在视图上有路径助手,但在<code>rake路由
尝试< code > redirect _ to wizard _ path(:picture)
你可以在这里找到更多关于邪恶助手的信息:https://github.com/schneems/wicked#quick-reference
这些帮助程序将在使用render_wizard
渲染的视图上可用。在向导外部,该步骤将作为 RESTful 路由的 :id
传递。要重定向到图片步骤中的boat_steps/显示,请尝试redirect_to boat_step_path(id::p icture)
。生成的网址应为 /boat_steps/picture
。
del key1 key2 ....keyN 返回1表示存在,0不存在
主要内容:验证删除结果其他开发人员在更新他的本地存储库后,在目录中找到一个文件。查看提交消息后,了解到文件是由添加的。 现在,假设要对上面的项目中代码结构进行重构,代码文件:module.py 已经不再使用了,要将它删除,那么应该怎么做?请参考以下命令 - 验证删除结果 在另外一台电脑上,执行以下命令更新当前工作区,查看 目录中的文件是否还存在?
我有一个登录表单,在单击时调用以下函数。 然后使用重定向 但我面临的问题是,当我第一次登录时,重定向无法工作。它设置了所有的cookie等等,但是它从来没有将用户重定向到想要的目录。所以我被迫在浏览器搜索栏中输入我想要的路由来重定向自己。 这意味着,一旦我强迫自己进入想要的目录,如果我注销(基本上删除cookies),并尝试再次登录。这一次重定向起作用了。 在我用Ctrl+F5清除所有缓存之前,它
命令用于从数据库和不同模式中删除表。参考以下步骤: 假设要从模式 db2inst1 中删除表。 可以看到该表在列表中可用,然后点击Execute SQL ,如下所示: 可以看到,表已经被删除了。如下图所示:
如果要从数据库中删除某些记录,则需要DELETE操作。 以下程序显示了从AGE超过20的EMPLOYEE中删除所有记录的过程。 例子 (Example) /* Main program */ Call RxFuncAdd 'SQLLoadFuncs', 'rexxsql', 'SQLLoadFuncs' Call SQLLoadFuncs if SQLConnect(c1,'testuser
我是一个使用ASP.NET MVC5的新手。我需要对控制器进行Jquery调用,以返回一个传递单个参数的新视图。我可以看到很多类似MVC3和之前版本的例子,但却很难找到任何处理MVC4或MVC5并起作用的例子。我所要做的就是从输入元素获取一个值,将其传递给控制器ActionResult,然后打开一个新视图。 PageTwo是视图,Home是控制器。 我试过的代码(包括许多其他代码)通常在404: