在我的Ruby on Rails应用程序中,我尝试以Base64格式通过POSTMAN REST客户端上传图像.当我发布图像时,我得到了406 Not Acceptable Response.当我检查我的数据库时,图像就在那里并成功保存.
这个错误的原因是什么,我需要在标题中指定什么?
我的请求:
网址--- http://localhost:3000/exercises.json
标题:
Content-Type - application/json
Run Code Online (Sandbox Code Playgroud)
原始数据:
{
"exercise": {
"subbodypart_ids": [
"1",
"2"
],
"name": "Exercise14"
},
"image_file_name": "Pressurebar Above.jpg",
"image":"******base64 Format*******"
}
Run Code Online (Sandbox Code Playgroud) 我有一个Rails应用程序,试图一次删除多个对象.
我试过发送一组由','分隔的id到rails destroy方法,但它只销毁单个对象.是否可以删除rails 3中的多个对象.
我正在构建一个Rails 4 Web应用程序,我想在我的应用程序中包含一些.js文件.是否可以直接将JavaScript文件添加到我的Rails ..app/assets/javascripts
文件夹并在application.js中添加这样的引用?
//= customejsfile.js
Run Code Online (Sandbox Code Playgroud)
这是正确的方法吗?如果是的话,我是否可以按照添加jQuery和Bootstrap库的相同步骤进行操作?
任何帮助表示赞赏.
javascript jquery ruby-on-rails twitter-bootstrap ruby-on-rails-4
我正在开发一个asp.net MVC4项目,我使用大量的JqueryUI datepicker.
对于我的日期选择器之一,当我试图点击datepicker图像时,我得到一些错误,如,
Uncaught TypeError: Cannot read property 'settings' of undefined jquery-ui-1.10.3.min.js:9
Run Code Online (Sandbox Code Playgroud)
HTML
<div>
<input type="text" id="tsDte" style="font-size: 14px;width: 50%" >
<img src="~/Images/dayPicker.png" onclick="tsDatePickerClick()" style="vertical-align:bottom"/>
</div>
Run Code Online (Sandbox Code Playgroud)
使用Javascript
var currentDate = new Date();
$("#tsDte").datepicker({
dateFormat: 'yy-mm-dd',
maxDate: 0,
changeYear: true
}).attr('readonly', 'readonly');
$("#tsDte").datepicker("setDate", currentDate);
function tsDatePickerClick() {
$("#tsDte").datepicker('show');
}
Run Code Online (Sandbox Code Playgroud)
这里我有一个Textfield和一个datepicker图像.当我点击datepicker图像时,会弹出一个datepicker.
我在其他datepicker中遵循了类似的方式,他们工作正常.我只有这个日期选择器的问题.
任何帮助表示赞赏.
我用Ruby v2和Rails v4开发了一个rails web项目.它完全在我当前的系统中工作,当我试图在另一台Linux机器(Ubuntu 12.4)中运行该项目时,我收到了一个Tidy_tds错误.
此错误在当时显示bundle install
,
错误详情如下
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/home/action/.rvm/rubies/ruby-2.1.1/bin/ruby extconf.rb
checking for iconv_open() in iconv.h... yes
checking for sybfront.h... no
-----
freetds is missing.
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/home/action/.rvm/rubies/ruby-2.1.1/bin/ruby
--enable-lookup
--disable-lookup
--with-iconv-dir
--without-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib …
Run Code Online (Sandbox Code Playgroud) 我有一个使用Device + doorkeeper的Rails应用程序.我也使用cancan进行角色管理.在我的应用程序中,我http://localhost:3000/oauth/applications/new
用于注册我的应用程序以获取Client和Secret id.目前任何用户都可以通过Web界面注册应用程序来获取客户端和机密ID,我需要限制访问权限,以便只有管理员可以注册应用程序.
我在doorkeeper.rb
文件中看到了一些代码
# If you want to restrict access to the web interface for adding oauth authorized applications, you need to declare the block below.
# admin_authenticator do
# # Put your admin authentication logic here.
# # Example implementation:
# Admin.find_by_id(session[:admin_id]) || redirect_to(new_admin_session_url)
# end
Run Code Online (Sandbox Code Playgroud)
我尝试过如下,但没有工作......
admin_authenticator do
if(current_user)
current_user.role? :admin
else
redirect_to(new_user_session_url)
end
end
Run Code Online (Sandbox Code Playgroud)
提前致谢......
ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1 ruby-on-rails-3.2
在我的Rails 3应用程序中,我有多个模型,每个模型都与另一个模型相关联.
User
模型
has_many :departments
accepts_nested_attributes_for :departments
Run Code Online (Sandbox Code Playgroud)
Department
模型
has_many :projects
accepts_nested_attributes_for :projects
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用JSON 通过邮递员REST客户端插入数据.我找到了一些格式,除了模型中有一个图像上传字段User
,我将用PaperClip
gem 处理.
通过我的rails视图它工作正常,但如何使用邮递员上传图像?
要通过REST客户端上传,我需要与我的图像等效的JSON格式.
有没有办法在json中嵌入图像所以我可以使用postman rest客户端?
我收到一个错误:
Missing partial post/questions, application/questions with
{:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}.
Searched in:* "/Users/..../<project name>/app/views"
Run Code Online (Sandbox Code Playgroud)
我试图将数据库中的所有帖子都渲染到index.html.erb
.
我的观点是post/index.html.erb
:
<!--html codes -->
<%= render 'questions' %>
Run Code Online (Sandbox Code Playgroud)
控制器controller/post_controller.rb
:
def index
@posts=Post.all
end
def questions
end
Run Code Online (Sandbox Code Playgroud)
questions.html.erb
<%=@posts.each do |post| %>
<table>
<tr>
<td>
<h2>
<%=post.title%>
</h2>
</td>
</tr>
<tr>
<td>
<h3><%=post.body%></h3>
</td>
</tr>
<tr>
<td>
This Post comes under:<h4><%=post.tag%></h4>
</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud) 当我试图通过我的REST客户端发布数据时,我收到这样的警告
Warning :Can't verify CSRF token authenticity.
Run Code Online (Sandbox Code Playgroud)
怎么解决这个问题.
我有模型注册表,基于部门和组来标记用户的出席.每个用户都有一个部门和组.
注册模型
date:date , departmentid:string , groupid:integer , one:integer , two:integer
Run Code Online (Sandbox Code Playgroud)
在上述字段中,"一个和两个"是时间段(例如:从9-14,14-18).Artndance被标记为用户属于当前日期,groupid,departmentid.So同一天将有多个条目groupid,departmentid和他们的出席.
样本注册表如下
我想找不到.每天注意的用户数.目前我已经尝试过
@register = Register.where(:date=>"2012-12-28").sum(:one)
Run Code Online (Sandbox Code Playgroud)
它变得很好,但我想找到像,
@register = Register.where(:date=>"2012-12-28").sum(:one , :two ,:three)
Run Code Online (Sandbox Code Playgroud)
可能吗....
提前致谢.
javascript ×2
jquery ×2
json ×2
ruby ×2
binary-data ×1
http ×1
jquery-ui ×1
paperclip ×1
rest ×1