如何检查Ubuntu Server上的rails环境?
命令:Rails.env => command not found
命令: rails.env => command not found
在项目中我有这个表:
还有Product型号(id, name, catalogId, catalogTitle, manufacturerId, manufacturerName).
如果我想获得Product项,如何在Linq中写下这个SQL查询?
SELECT Product.Name, Product.CatalogId, Product.ManufacturerId, [Catalog].Name, Manufacturer.Name
FROM Product, [Catalog], Manufacturer
WHERE [Catalog].Id=Product.CatalogId AND Manufacturer.id=Product.ManufacturerId AND Product.Active=1
Run Code Online (Sandbox Code Playgroud) 我有3个MySQL表(food,apple,和orange).
我想删除以下行:
apple(idapple, iduser, name)
orange(idornge, iduser, name)
Run Code Online (Sandbox Code Playgroud)
food(iduser, name)使用一个触发器删除行时?
到目前为止,这是我的触发器:
CREATE TRIGGER `food_before_delete`
AFTER DELETE ON `food`
FOR EACH ROW
DELETE FROM apple, orange
WHERE
apple.iduser=OLD.iduser and
orange.iduser=OLD.iduser
Run Code Online (Sandbox Code Playgroud)
但它不会编译.如何制作一次从两个表中删除的触发器?
我无法设置RatingBar的评级.我的代码如下.如何为动态添加的RatingBar设置默认评级?
这是我的代码.
public class DialogRate extends Activity implements OnRatingBarChangeListener {
...
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog_layout);
LinearLayout ll_dialog = (LinearLayout) findViewById(R.id.linearLayout_dialog);
final RatingBar rate_bar = new RatingBar(context);
rate_bar.setOnRatingBarChangeListener(this);
rate_bar.setStepSize((float) 0.5);
rate_bar.setMax(5);
rate_bar.setId(1);
rate_bar.setRating(2.0f); // Error occur on this line!
ll_dialog.addView(rate_bar);
}
...
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
// TODO Auto-generated method stub
TextView rate_val = (TextView) findViewById(0);
rate_val.setText(Float.toString(ratingBar.getRating()));
}
Run Code Online (Sandbox Code Playgroud)
错误堆栈:
Thread [<1> main] (Suspended)
ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 1645
ActivityThread.handleLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 1663
ActivityThread.access$1500(ActivityThread, …Run Code Online (Sandbox Code Playgroud) 我有这条路线:
routes.MapRoute(
"News",
"News/{id}-{alias}",
new { controller = "News", action = "Show" },
new
{
id = @"^[0-9]+$"
},
namespaces: new[] { "Site.Controllers" }
);
Run Code Online (Sandbox Code Playgroud)
这条路线适用于这样的网址:
http://localhost:54010/News/6-news
Run Code Online (Sandbox Code Playgroud)
但不适用于这样的网址:
http://localhost:54010/News/6-nice-news
Run Code Online (Sandbox Code Playgroud)
如何在我的路由值“别名”中使用破折号?
已编辑
路线是这样的:
"News/{id}_{alias}"
Run Code Online (Sandbox Code Playgroud)
适用于两个网址:
http://localhost:54010/News/6_news
http://localhost:54010/News/6_nice-news
Run Code Online (Sandbox Code Playgroud) asp.net asp.net-mvc routing asp.net-mvc-routing asp.net-mvc-3
我有这个课程:
class Fruit
attr_accessible :name, :position
has_many :apples
default_scope order('position ASC')
end
class Apple
attr_accessible :name
belongs_to :fruit
end
Run Code Online (Sandbox Code Playgroud)
怎么按fruit.position排序苹果?
我无法理解我的代码有什么问题(Rails 4):
来自帖子的参数:
{:name => "name"}
Run Code Online (Sandbox Code Playgroud)
新动作:
m=Menu.new(params.permit(:name))
Run Code Online (Sandbox Code Playgroud)
此代码的最后一行生成"无法为菜单:名称大量分配受保护的属性"
我现在正在使用Carrierwave上传图片.一切都很好,除了一个, - 当我添加复选框以删除上传的图像时,我收到错误:"无法批量分配受保护的属性:remove_image".
形成:
...
<%= f.check_box :remove_image %>
<%= f.label :remove_image, "remove image" %>
...
Run Code Online (Sandbox Code Playgroud)
模型:
class Manufacturer < ActiveRecord::Base
attr_accessible :name, :alias, :short_description, :long_description, :image, :publish,
:position, :meta_keywords, :meta_description, :meta_title
mount_uploader :image, ManufacturerUploader
validates_presence_of :name, :alias
validates_uniqueness_of :name, :alias
validates_format_of :alias, :with => /^[a-z\d\-]*$/, :message => "a-z, 0-9 \' - \' ONLY"
default_scope order('position ASC')
before_destroy :remember_image
after_destroy :remove_img
protected
def remember_image
@image_name = self[:image]
end
def remove_img
File.delete("#{Rails.root}/public/images/manufacturer/#{@image_name}")
File.delete("#{Rails.root}/public/images/manufacturer/thumb_#{@image_name}")
end
end
Run Code Online (Sandbox Code Playgroud)
提供者:
class ManufacturerUploader < CarrierWave::Uploader::Base
include …Run Code Online (Sandbox Code Playgroud) 我有一个奇怪的错误 - 目录中的图像“403 Forbidden” public/images。但是来自嵌套目录的其他图像加载没有问题(ig from public/images/product)。我正在使用 Nginx + 乘客 + capistrano。在 production.rb 我有config.serve_static_assets = true. 也许资产管道出错?
我的桌子:
表格1
id|name_transfer|id_account_from|value_from|id_account_to|value_to
------------------------------------------------------------------
1 |transfer1 |1 |1000 |2 |1000
Run Code Online (Sandbox Code Playgroud)
表2
id|name_account|
----------------
1 |account1 |
2 |account2 |
Run Code Online (Sandbox Code Playgroud)
如何编写查询,我给出了这个:
transfer1|account1|1000|account2|1000
Run Code Online (Sandbox Code Playgroud) 当我使用jQuery.ajax和POST方法从数据库中删除项目时,我收到此错误:
GET Http://localhost:54010/Admin/Category/Delete?id=77 404 Not Found
Run Code Online (Sandbox Code Playgroud)
CategoryController中的操作:
[HttpPost]
public ActionResult Delete(int id) {
try {
db.CategoryRepository.Delete(id);
db.Save();
return Json(new {Result = "OK"});
} catch (Exception ex) {
return Json(new { Result = "ERROR", Message = ex.Message });
}
}
Run Code Online (Sandbox Code Playgroud)
视图:
<a id="delete-category" class="btn btn-small" href="#">
<i class="icon-remove"></i>
@Resource.delete
</a>
Run Code Online (Sandbox Code Playgroud)
JavaScript的:
$(function () {
$('#delete-category').click(function (event) {
event.preventDefault();
$.ajax({
method: 'POST',
url: '@Url.Action("Delete","Category")',
dataType: 'json',
data: { id: '@Model.CategoryModel.Id' },
success: function (data, textStatus, jqXHR) {
console.log("success");
},
error: function () …Run Code Online (Sandbox Code Playgroud) mysql ×2
select ×2
activerecord ×1
ajax ×1
android ×1
asp.net ×1
asp.net-mvc ×1
c# ×1
carrierwave ×1
file-upload ×1
jquery ×1
linq ×1
nginx ×1
post ×1
production ×1
routing ×1
ruby ×1
sql ×1
sql-delete ×1
triggers ×1
ubuntu ×1