有关belongs_to的条件(Conditions on belongs_to)
我有这种叫做
Request
模型,它belongs_to
User
。class Request < ActiveRecord::Base belongs_to :user, :conditions => "can_make_requests = t" end
User
模型在其架构中有一个名为can_make_requests
的布尔字段,但出于某种原因,当我尝试时aUser.requests.create
当
aUser
具有can_make_requests
作为f
,它仍然有效(aUser.requests.first
返回新创建的请求)。 有谁知道这个问题是什么?I have this model called
Request
, whichbelongs_to
aUser
.class Request < ActiveRecord::Base belongs_to :user, :conditions => "can_make_requests = t" end
The
User
model has a boolean field in its schema namedcan_make_requests
, but for some reason, when I tryaUser.requests.create
when
aUser
hascan_make_requests
asf
, it still works (aUser.requests.first
returns the newly made request). Does anyone know what the issue is?
原文:https://stackoverflow.com/questions/6241437
更新时间:2022-04-01 16:04
最满意答案
EditText hex; Button ok; RelativeLayout baselayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); hex = (EditText)findViewById(R.id.hex); ok = (Button)findViewById(R.id.btn); baseLayout=(RelativeLayout)findViewById(R.id.layout); ok.setOnClickListener(new OnclickListener){ @Override public void onClick(View v) { String colorString=hex.getText().toString(); //Validate Color before setting try { Color filteredColor = Color.parseColor(colorString); baseLayout.setBackgroundColor(filteredColor); } catch (IllegalArgumentException iae) { // This color string is not valid } } } }
EditText hex; Button ok; RelativeLayout baselayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); hex = (EditText)findViewById(R.id.hex); ok = (Button)findViewById(R.id.btn); baseLayout=(RelativeLayout)findViewById(R.id.layout); ok.setOnClickListener(new OnclickListener){ @Override public void onClick(View v) { String colorString=hex.getText().toString(); //Validate Color before setting try { Color filteredColor = Color.parseColor(colorString); baseLayout.setBackgroundColor(filteredColor); } catch (IllegalArgumentException iae) { // This color string is not valid } } } }
相关问答
更多-
EditText hex; Button ok; RelativeLayout baselayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); hex = (EditText)findViewById(R.id.hex); ok = (B ...
-
尝试: String networkPass = "73757065726d616e"; Try: String networkPass = "73757065726d616e";
-
假设这是您的XML布局文件使用ColorDrawable和Color.parseColor("#FFFFFF")如下所示: ColorDrawable cd = new ColorDrawable(Color.parseColor("#FFFFFF")); holder.image.setForeground(cd); Use ColorDrawable with Color.parseColor("#FFFFFF") like so: ColorDrawable cd = new ColorDrawable(Co ...尽管大多数代码都不起作用且不可重现,将“red”更改为“5182BA”似乎工作正常。 ggplot(bay, aes(x=medprice.n2, y=wbi)) + geom_smooth(method=lm, size=1.3, colour="#5182BA") Altough most of your code does not work and is not reproducible, changing "red" to "5182BA" seems to work fine. ggp ...setRGB()对于坐标取两个int值,一个表示颜色。 颜色的Hexcodes通常由3或4个2 Hex值的分组组成,如下所示: 0xFF00FF00 上面的代码将代表一个完整的绿色与完整的阿尔法。 这是因为两个十六进制代码的第一个分组与第二个红色,第三个绿色和第四个蓝色相对应。 所以,你可以把所有这些值放到int因为int是32位长。 每个十六进制代码的长度是8位。 为此,您需要将值移到左侧。 试试以上我们的颜色示例: int color = (0xFF<<24) | (0x00<<16) | (0xFF ...您必须将“#”替换为“0xff”才能获得所需内容。 使用短数字(仅限三个分量),alpha通道将始终为0,颜色将完全透明。 使用0xff后跟六个十六进制数字作为RGB颜色,您将获得具有完全不透明度的颜色。 更新:使用当前版本的MigraDoc 1.50(beta 5b或更高版本),您还可以使用哈希符号,后跟3个,6个或8个十六进制数字。 8位数字包括alpha通道,使用3或6位数字表示FF的alpha设置。 使用新版本,代码#ADD8E6将具有预期的效果。 使用0x前缀时没有任何改变。 You have t ...$('#mycolor').val = currentHex; //wrong syntax 应该 $('#mycolor').val(currentHex); 更新了演示 $('#mycolor').val = currentHex; //wrong syntax should be $('#mycolor').val(currentHex); Updated Demo通过GridPagerAdapter构造函数传递布局并保存在变量中。 private static final class GridPagerAdapter extends FragmentGridPagerAdapter { private final FrameLayout li; String[][] mData; private GridPagerAdapter(FragmentManager fm, String[][] data, FrameLayout li) ...大于0x7fff_ffff值太大而无法作为signed ints.处理ints. Java 8添加了处理ints方法,就好像它们包含无符号值一样。 只需用parseUnsignedInt:替换parseInt parseUnsignedInt: Integer.parseUnsignedInt("ffaaaaaa", 16) 如果需要使用Java 7及更早版本,可以将其解析为long ,然后将其转换为int. 或者,如果值是常量,您可以将它们写为数字常量,如0xffaaaaaa甚至0xffaa_aaaa并 ...
相关文章
更多- 关于不定条件写法的问题
- 有关MVC的问题
- 有关struts的一个问题
- ext 的store中 baseParams.conditions 是什么意思啊?
- Groovy 条件语句
- 基于Solr的HBase多条件查询测试
- HBase多条件筛选查询方案
- Solr的HBase多条件查询
- solr实现满足指定距离范围条件的搜索
- Nutch1.4相关
最新问答
更多- python的访问器方法有哪些
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。
- 响应navi重叠h1和nav上的h1链接不起作用(Responsive navi overlaps h1 and navi links on h1 isn't working)
- 在C中读取文件:“r”和“a +”标志的不同行为(Reading a File in C: different behavior for “r” and “a+” flags)
- NFC提供什么样的带宽?(What Kind of Bandwidth does NFC Provide?)
元素上的盒子阴影行为(box-shadow behaviour on elements) - Laravel检查是否存在记录(Laravel Checking If a Record Exists)
- 设置base64图像的大小javascript - angularjs(set size of a base64 image javascript - angularjs)
- 想学Linux 运维 深圳有哪个培训机构好一点
- 为什么有时不需要在lambda中捕获一个常量变量?(Why is a const variable sometimes not required to be captured in a lambda?)
- 在Framework 3.5中使用服务器标签<%=%>设置Visible属性(Set Visible property with server tag <%= %> in Framework 3.5)
- AdoNetAppender中的log4net连接类型无效(log4net connection type invalid in AdoNetAppender)
- 错误:发送后无法设置标题。(Error: Can't set headers after they are sent. authentication system)
- 等待EC2实例重启(Wait for an EC2 instance to reboot)
- 如何在红宝石中使用正则表达式?(How to do this in regex in ruby?)
- 使用鼠标在OpenGL GLUT中绘制多边形(Draw a polygon in OpenGL GLUT with mouse)
- 江民杀毒软件的KSysnon.sys模块是什么东西?
- 处理器在传递到add_xpath()或add_value()时调用了什么顺序?(What order are processors called when passed into add_xpath() or add_value()?)
- sp_updatestats是否导致SQL Server 2005中无法访问表?(Does sp_updatestats cause tables to be inaccessible in SQL Server 2005?)
- 如何创建一个可以与持续运行的服务交互的CLI,类似于MySQL的shell?(How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?)
- AESGCM解密失败的MAC(AESGCM decryption failing with MAC)
- SQL查询,其中字段不包含$ x(SQL Query Where Field DOES NOT Contain $x)
- PerSession与PerCall(PerSession vs. PerCall)
- C#:有两个构造函数的对象:如何限制哪些属性设置在一起?(C#: Object having two constructors: how to limit which properties are set together?)
- 平衡一个精灵(Balancing a sprite)
- n2cms Asp.net在“文件”菜单上给出错误(文件管理器)(n2cms Asp.net give error on Files menu (File Manager))
- Zurb Foundation 4 - 嵌套网格对齐问题(Zurb Foundation 4 - Nested grid alignment issues)
- 湖北京山哪里有修平板计算机的