我试图用自己的百分比来调整img的大小.例如,我只想将图像缩小到50%,将图像缩小一半.但是应用width: 50%;会将图像的大小调整为容器元素的50%(<body>例如,可能是父元素).
问题是,我可以在不使用javascript或服务器端的情况下用一定比例调整图像大小吗?(我没有图像大小的直接信息)
我很确定你不能这样做,但我只想看看是否有智能的CSS解决方案.谢谢!
我试图用Ember和Ember Data做一些非常基本的事情.
1)帖子属于用户; 用户有很多帖子
2)在创建新的Post表单中,我想要选择/下拉所有用户
3)当我编辑帖子(使用相同的表单)时,我想将其正确绑定回dropbox
问题:执行与用户列表绑定的下拉列表的最佳做法是什么?如何绑定编辑表单以再次填充下拉列表?
用户模型:
App.User = DS.Model.extend({
posts: DS.hasMany('post', {async: true}),
});
Run Code Online (Sandbox Code Playgroud)
邮政模式:
App.Post = DS.Model.extend(Ember.Validations.Mixin, {
user: DS.belongsTo('user', {async: true}),
});
Run Code Online (Sandbox Code Playgroud)
创建新的职位表格:
{{view Em.Select
content=users <<<<< How do I bind this.store.find("user") here?
optionValuePath='content.id'
optionLabelPath='content.name'
}}
Run Code Online (Sandbox Code Playgroud)
我不明白将选择内容与用户绑定的最佳做法.
尝试1:
*我使用的是Ember-Form
{{em-select
property="user_id"
label="user"
prompt="Select user:"
content=controllers.users.content
optionValuePath="content.id"
optionLabelPath="content.first_name"
}}
Run Code Online (Sandbox Code Playgroud)
在保存操作上:
newItem.set('user', this.store.getById('user', this.get('user_id')));
Run Code Online (Sandbox Code Playgroud)
我尝试使用user_id作为表单的属性,并在保存时转换回用户对象以分配给帖子.但是,这种方法有点愚蠢,因为我每次保存时都会主动将user_id转换为用户对象.我觉得应该有一种方法可以自动完成,如果我做了正确的绑定,而不是跳过箍来绑定属性user_id.当我使用相同的表单编辑帖子时,这也使我很难绑定回来.由于已经建立了所有的关系,我觉得我在这里做错了.我认为必须有更好的方法.
谢谢!
我正在使用assets_sync运行Rails 3.2.
创建了我的css和js的gz版本.CloudFront不提供gzip版本,即使请求gzip,deflate的头.
我也尝试过config.gzip_compression = true,asset_sync.rb但CloudFront仍在提供未压缩版本.我已经确认我可以访问ABC.cloudfront.net/XYZ.css.gz
我在users_spec.rb中有这个
scenario "Go to contact page" do
visit "/contact"
current_path.should == contact_path
end
Run Code Online (Sandbox Code Playgroud)
运行rspec后,我明白了
Failure/Error: current_path.should == contact_path
expected: "/contact"
got: nil (using ==)
Run Code Online (Sandbox Code Playgroud)
出于某种原因,current_path似乎返回nil.有没有我错过的配置?
在对象模型中,我有
has_many :likes
has_many :hates
has_many :users, :through => :likes
has_many :users, :through => :hates
Run Code Online (Sandbox Code Playgroud)
如何获取喜欢的用户列表?例如object.users <---但是如何通过喜欢或讨厌来指定?
我正在创建一个名为user_info的用户的一对一关系.以下是工作解决方案.
在user.rb中
has_one :user_info
accepts_nested_attributes_for :user_info, :allow_destroy => true
attr_accessible :username, :email, :password, :password_confirmation, :remember_me, :user_info_attributes
Run Code Online (Sandbox Code Playgroud)
在user_info.rb中
belongs_to :user
attr_accessible :first_name, :last_name
Run Code Online (Sandbox Code Playgroud)
在devise/registrations/edit.html.erb中
<% resource.build_user_info if resource.user_info.nil? %>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
...
<%= f.fields_for :user_info do |info| %>
<%= info.text_field :first_name %>
Run Code Online (Sandbox Code Playgroud)
我知道我不应该在视图中包含构建.但我不想"触摸"设计控制器或模型.这是最简单的方法.
我必须遗漏一些非常简单的东西,但我找不到其他人的问题.基本上,Rails 3.1将所有.css文件合并到application.css中.安装ActiveAdmin后,ActiveAdmin的CSS也合并到application.css中,导致冲突并覆盖我的样式表.
我在这里错过了什么?
activeadmin ×1
activerecord ×1
amazon-s3 ×1
capybara ×1
css ×1
devise ×1
ember-data ×1
ember.js ×1
gzip ×1
heroku ×1
html ×1
image ×1
rspec ×1