没有传递给新行动的参数(Params not being passed to new action)
我在视图中有一个表单:
<%= form_tag(new_admin_course_path(chichi: @provider.id), {method: :get}) do %> <%= submit_tag I18n.t('views.courses.index.add_new') %> <% end %>
@provider.id
等于1(与Pry
检查)。
new_admin_course_path
落在courses_controller#new
。 从动作本身(使用binding.pry
帮助)我得到了params
的内容,这是我发现的:pry(#<Admin::CoursesController>)> params => {"utf8"=>"✓", "commit"=>"Add course", "controller"=>"admin/courses", "action"=>"new"}
我不是新的Rails,但我不知道为什么会发生这种情况,而且我没有得到我通过辅助方法传递的信息。
任何想法为什么发生这种情况?
I have a form in the view:
<%= form_tag(new_admin_course_path(chichi: @provider.id), {method: :get}) do %> <%= submit_tag I18n.t('views.courses.index.add_new') %> <% end %>
@provider.id
is equal to 1 (checked withPry
).
new_admin_course_path
lands incourses_controller#new
. From the action itself (withbinding.pry
help) I got the content ofparams
and this is what I found:pry(#<Admin::CoursesController>)> params => {"utf8"=>"✓", "commit"=>"Add course", "controller"=>"admin/courses", "action"=>"new"}
I'm not new in Rails, but I have no idea why this is happening and I'm not getting what I pass through the helper method.
Any idea why this is happening?
原文:https://stackoverflow.com/questions/33752938
最满意答案
This appears to be Not Implemented (yet). https://github.com/aspnet/EntityFramework/issues/3459
相关问答
更多-
解决方法是为date2类型实体使用DateTime.Date 。 var compareDate = DateTime.Now.AddDays(-5).Date; 谢谢。 Workaround is to use a DateTime.Date for date2 type entities. var compareDate = DateTime.Now.AddDays(-5).Date; Thanks.
-
将其更改为两个Any呼叫: return offer => offer.Restrictions .Any(rest => rest.OperatorRange .Where(alop => criteria.ServiceUseNet == null || alop.OperatorRange.ToUpper() == criteria.ServiceUseNet.ToUpper()) ...
-
实体框架中的假查询(Fake query in Entity Framework)[2021-11-12]
我也有类似的问题,我使用以下方法。 首先编写SP,然后声明尽可能多的变量,因为SP将在sp的末尾返回列,而不是写一个select语句,它将选择所有变量作为列,因此EF将找到SP的返回类型。 在拖动SP注释掉sp的实际代码之前,只写下select语句。 当您拖动SP注释时,在末尾写入的select语句和ucomment实际代码为SP。 例 Create Procedure TestSP Select col into #temp from Table select col from #temp //This ... -
查询联合查询(Query a union query)[2022-12-13]
所有都是保留字,你需要方括号。 SELECT [All].latd, [All].latm, [All].lats, [All].lond, [All].lonm, [All].lons, [All].freq FROM [All] WHERE latd =37 AND latm=53 AND lond=76 AND lonm=37; All is a reserved word, you need square brackets. SELECT [All].latd, [All].latm, [All ... -
实体框架查询映射问题(Entity Framework query mapping issue)[2023-05-15]
我想我会在这里留下答案以备将来参考。 实际问题是相当简单和愚蠢的。 我忘了在关系的另一边删除对Orders的引用。 也就是说,我有一个Campaign实体仍然保持对Order实体的引用,如下所示...... public class Campaign { public Campaign() { Orders = new HashSet(); } public virtual ICollection Orders {get;set; ... -
根据这个GitHub问题,服务器端UNION尚未在EF Core 2.0.1中实现。 服务器端UNION计划在EF Core v.2.1中实现,直到那时EF将执行本地联盟(在内存中)。 According to this GitHub issue server-side UNION is simply not implemented yet in EF Core 2.0.1. Server-side UNION is planned to be implemented in EF Core v. 2.1, ...
-
看起来你的模型使用的是Ardent,而不是Eloquent: ...instance of LaravelBook\Ardent\Builder given, ... 也许这可能是Ardent的一个问题,而不是Laravel。 在这里打开一个问题: https : //github.com/laravelbook/ardent 。 编辑: 尝试更改使用QueryBuilder而不是Eloquent: 用于QueryBuilder: DB::table('tags')-> 而不是雄辩的方式: Tag:: ...
-
实体框架查询加入问题(Entity Framework Query Join issue)[2019-10-11]
我不得不猜测你的课程是什么样子,但看看这段代码:( https://dotnetfiddle.net/TVqzse ) 这个片段对你来说最有趣: var favoriteColours = people.SelectMany(p => p.FavouriteColours); foreach(var favoriteColour in favoriteColours) { System.Console.WriteLine(favoriteColour.Color.ColorName); } ... -
这似乎是未实施(尚未)。 https://github.com/aspnet/EntityFramework/issues/3459 This appears to be Not Implemented (yet). https://github.com/aspnet/EntityFramework/issues/3459
-
如果您倾向于使用纯LINQ进行此操作,则可以对组内的值进行分组,然后进行前4。 var result = db.Products.GroupBy(p => p.CategoryID).SelectMany(g => g.Take(4)); 如果你对两行没问题,你也可以使用编译的查询: var query = CompiledQuery.Compile
>(( ctx, filter, top) => ...