Javascript ActiveSupport::MessageVerifier::InvalidSignature
我正在尝试创建一个表单,用户可以在其中编辑现有的视频标题和描述。当发送补丁请求时,我得到以下错误。另一篇关于StackOverflow的帖子说,如果发送的是字符串而不是对象,则会导致错误,但我在控制台记录对象时看到它。有什么想法吗 视频控制器:Javascript ActiveSupport::MessageVerifier::InvalidSignature,javascript,ruby-on-rails,amazon-s3,Javascript,Ruby On Rails,Amazon S3,我正在尝试创建一个表单,用户可以在其中编辑现有的视频标题和描述。当发送补丁请求时,我得到以下错误。另一篇关于StackOverflow的帖子说,如果发送的是字符串而不是对象,则会导致错误,但我在控制台记录对象时看到它。有什么想法吗 视频控制器: def update @video = Video.find(params[:id]) if @video.update(video_params) render :show el
def update
@video = Video.find(params[:id])
if @video.update(video_params)
render :show
else
render json: @video.errors.full_messages, status: 422
end
end
def video_params
params.require(:video).permit(:video_title, :video_description, :owner_id, :video_url)
end
编辑容器
import { connect } from 'react-redux';
import Edit from './edit';
import { fetchVideo, updateVideo } from '../../actions/video_actions';
const mSTP = ( state, ownProps ) => {
return {
// video: state.entities.videos[state.session.id],
video: state.entities.videos[ownProps.match.params.id],
// errors: state.errors
}
};
const mDTP = dispatch => ({
fetchVideo: videoId => dispatch(fetchVideo(videoId)),
updateVideo: video => dispatch(updateVideo(video)),
});
export default connect(mSTP, mDTP)(Edit);
编辑表格
class Edit extends React.Component {
constructor(props) {
super(props)
this.state = {
video_id: this.props.match.params.id,
video_title: "",
video_description: "",
}
this.handleSubmit = this.handleSubmit.bind(this);
}
update(field) {
return (e) => {
this.setState({
[field]: e.currentTarget.value
})
}
}
handleSubmit() {
// debugger
//this.props.updateVideo(this.state.video_id)
const { video_id, ...rest } = this.state
this.props.updateVideo(video_id, { video: { ...rest } })
}
render() {
return (
<div className="edit-container">
<form className="edit-form" onSubmit={this.handleSubmit}>
<label>
<input
type="text"
value={this.state.video_title}
placeholder="Your video's title"
onChange={this.update("video_title")}
/>
<div>{this.state.video_title}</div>
</label>
<label>
<input
type="textarea"
value={this.state.video_description}
placeholder="Your video's description"
onChange={this.update("video_description")}
/>
</label>
<button>Edit</button>
</form>
</div>
);
}
}
export default Edit;
类编辑扩展了React.Component{
建造师(道具){
超级(道具)
此.state={
video_id:this.props.match.params.id,
视频标题:“,
视频描述:“,
}
this.handleSubmit=this.handleSubmit.bind(this);
}
更新(字段){
返回(e)=>{
这是我的国家({
[字段]:e.currentTarget.value
})
}
}
handleSubmit(){
//调试器
//this.props.updateVideo(this.state.video\u id)
const{video_id,…rest}=this.state
this.props.updateVideo(video_id,{video:{…rest})
}
render(){
返回(
{this.state.video_title}
编辑
);
}
}
导出默认编辑;
根据建议,将handleSubmit更改为携带尸体。我现在得到404,id未定义