rails-practice icon indicating copy to clipboard operation
rails-practice copied to clipboard

ruby菜鸟的问题

Open Rubyguo opened this issue 9 years ago • 7 comments

请教一下,我在导入cerulean之后在application.css中添加 *= require cerulean/loader *= require cerulean/bootswatch 后运行时在application.html.erb的<%= stylesheet_link_tag "application", :media => "all" %> 有一个错误variable @glyphiconsEotPath is undefined

Rubyguo avatar Dec 04 '15 04:12 Rubyguo

我还有个文件:bootstrap_and_overrides.css.less 里面有定义:https://github.com/liwei78/rails-practice-code/blob/master/final/app/assets/stylesheets/bootstrap_and_overrides.css.less#L14

如果这样还没解决,可以自己定义 @glyphiconsEotPath ,不过它也可能是 gem 升级过程中的 bug 或遗留问题。如果还不能解决,就把原始的代码放到自己项目里,自己改了。

liwei78 avatar Dec 04 '15 05:12 liwei78

我用你的bootstrap_and_overrides把我原来的替换了,但还是报这个错误,而且我之前的bootstrap_and_overrides文件中有@glyphiconsEotPath: font-url("glyphicons-halflings-regular.eot");的定义啊

Rubyguo avatar Dec 04 '15 12:12 Rubyguo

我把loader文件中的@import "twitter/bootstrap/glyphicons"注释掉之后可以运行了,但不知道为什么会出现这种情况

Rubyguo avatar Dec 05 '15 03:12 Rubyguo

恩,应该是 gem 升级导致的。 现在直接用 bootstrap 了,这个 gem 升级麻烦。

liwei78 avatar Dec 05 '15 04:12 liwei78

大神,还有一个问题请教。我在erb中建了一个<%= button_to booklist.id, home_postbook_path(@onebook), :id => booklist.id.to_s, :class => 'btn btn-xs btn-primary', :data => { :disable_with => '数据更新中' }, :remote => true %> 需要在后台的postbook方法中处理参数,但是每次点击按钮都要刷新页面,我想用jquery的方法更改按钮的样式,页面其他部分不变,如何实现

Rubyguo avatar Jan 01 '16 08:01 Rubyguo

hi,你说的两种方式,我在书里都提到了。一种是 ujs 发起的请求,通过返回的 js 片段来更新页面,一种是 ajax 发起的请求,通过success回调来更新页面。你再看看书里的部分,检查下是否引入了 jquery_ujs

liwei78 avatar Jan 01 '16 12:01 liwei78

我在后台方法中 def postbook @oneinbooklists = Booklist.find_by(id: params[:id]) @oneinbooklists.focus=true respond_to do |format| if(@oneinbooklists.save) format.html do redirect_to '/' end format.js {render postbook} else 。。。。。。 end end
end 但是用format.html会刷新页面,不用的话会ActionController::UnknownFormat报错,我想像使用模态框那样,阻断页面更新。请问有没有办法实现?

Rubyguo avatar Jan 05 '16 08:01 Rubyguo