This one is not holding me up, but I'm really curious what is happening.
I have in my application.css:
*= require_self
*= require conversations
and have some styles defined in my conversations.css, but they would not get picked up!
By chance, I renamed to conversations.css.scss and suddenly it started working. I renamed back to .css and it stopped.
I thought you could have either .css or .scss files and they would get picked up by rails (my version is 3.2.11)
Edit: I also tried this for .js files and the same behaviour. As soon as I add .coffee to any .js file, it gets picked up and used, otherwise, it does not.
Has anyone seen this behaviour before? If so, what is going on?
Related
I had a Rails 4 app that was loading the css.scss files just fine. Then I did something to break it, I don't know what, and reverting to the last git check-in isn't fixing the problem.
My structure is exactly as rails new [project name] left it, and I've never had to look at how the assets get loaded. Reading up on the asset pipeline just left me more confused.
I'm actually putting all of my styling in app\assets\stylesheets\application.css.scss, which begins with
*= require_self
*= require_tree .
as I believe it should, but (judging from the Chrome developer tools view) the application isn't even getting as far as loading that. So where does a Rails 4 application get told to load app\assets\stylesheets\application.css.scss?
(Yes, I see others have problems with loading the stylesheets, but the advice always seems to be to put the stylesheets where I already have them or to include those lines in the application stylesheet that I already have, so it looks as if my problem is something else).
I know that for every controller, there's a separate SASS and CoffeeScript file to keep things organized. But what about styling the application layout itself? How is it that there's no files to put all the styling and JS related to the whole layout?
I know there's application.css and application.js, but I Know these are not to be messed with because these files put everything together.
I hope someone could put me in the right track!
the application.css and application.js are manifest file and there you can see require_tree . that load all your js file for application.js and in same manner for application.css now on compiling assets pipeline make a minified version of that and create only one file that hold all the js in itself if you want to create two manifest file you can also do that .
Having problems with Rails 3.2.3
I have 3 CSS files in /assets/stylesheets:
application.css (has require_self & require_tree .)
bootstrap.css
myapp.css
Running rails server on localhost:3000, all is well
Whenever I change a CSS property, it gets updated in the view (e.g. change a color). However, whenever I delete a CSS property, nothing happens. In fact, I can remove all the text from all the CSS files and nothing will change.
I've tried resetting everything: rails server, clear browser everything, restart all programs, to no avail.
Anyone know what is wrong?
Edit: this problem started after I ran
rake assets:precompile
and the "fallback" CSS style when I delete properties from the static CSS files (i.e. what it will default to) is based on whatever the CSS files looked like last time I ran rake assets:precompile
Rake assets:clean
will work for you, as u ll be having compiled css and javascript files in your public folder, so by removing those your problem will be solved.
Every time I change a .coffee file in the development mode, Rails creates a corresponding .js file in the same /javascripts directory. With the result that Rails ends up processing both the files and therefore instead of firing an event once, I end getting that event firing twice. I have to remember to manually delete the .js file so I get the correct and anticipated behavior.
My question is: how can I prevent Rails from generating the .js file in the first place? Is it not supposed to compile the .coffee file in memory in the development mode? when I delete the generated .js file, I get the correct and anticipated behavior?
Thanks.
Bharat
Check the <head> section of your page. You check it by viewing the source of the page when running your app. If you do so I would bet that you will see one or more .js files that are included twice. Make sure you don't have unnecessary javascript_include_tags somewhere in your views.
Unless you changed the default require statements in app/assets/javascripts/application.js, any javascript files that are in there are being automatically included as long as your layout is set to include them (which it is by default).
Specifically, if you have this line in your application.js:
//= require_tree .
or
//= require_directory .
That will cause all .js files in the app/assets/javascripts directory (and sub directories if you have require_tree) to be included where you have the following in your page:
<%= javascript_include_tag 'application' %>
Usually this will be the case as it will be in your default layout (in app/views/layouts/application.html.erb).
So if they are already included in your layout you want to make sure you're not including them again any other way.
Another thing you could try is to remove the include from your layout and then just include javascript files manually per view using javascript_include_tag.
So I've started building a gem, which is difficult, but it seems to be working out so far..
Except for one little thing, the assets. I've tried putting them in my lib/assets, app/assets and vendor/assets. But they don't seem to load.
I have a test-app which loads my gem to test it, but nothing seems to work. I have an engine in my gem which I'm sure is being loaded.
What more do I need to know for this to start working?
EDIT:
here is my engine (located in lib/baco/engine.rb):
require 'rails'
module Baco
class Engine < Rails::Engine
end
end
EDIT 2:
This is my css file (located in vendor/assets/stylesheets/application.css.scss):
/*
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require_self
*= require baco
*/
input {
padding:10px;
}
Turns out I still need to require the the css from the app that is loading the gem..
Is this a normal situation? Because I haven't read about that anywhere..
Anyways, got it to work, thanks for looking into it, hope this topic can helps some others out..