I bought a theme and want to apply the whole theme into my site.
I put the line in the scss file
*= require_tree ../../../vendor/assets/lenord-single-page-theme/css
but it didn't include the folder I want
Rails.application.config.assets.paths
=> ["pixnet_hackathon/website/dqa_streesful_server/app/assets/ace-admin-theme",
"pixnet_hackathon/website/dqa_streesful_server/app/assets/images",
"pixnet_hackathon/website/dqa_streesful_server/app/assets/javascripts",
"pixnet_hackathon/website/dqa_streesful_server/app/assets/lenord-single-page-theme",
"pixnet_hackathon/website/dqa_streesful_server/app/assets/stylesheets",
"pixnet_hackathon/website/dqa_streesful_server/vendor/assets/javascripts",
"pixnet_hackathon/website/dqa_streesful_server/vendor/assets/stylesheets",
".rvm/gems/ruby-2.1.0/gems/simple-navigation-bootstrap-1.0.0/vendor/assets/stylesheets",
".rvm/gems/ruby-2.1.0/gems/bourbon-3.1.8/app/assets/stylesheets",
".rvm/gems/ruby-2.1.0/gems/tinymce-rails-4.0.19/app/assets/javascripts",
".rvm/gems/ruby-2.1.0/gems/tinymce-rails-4.0.19/app/assets/source",
".rvm/gems/ruby-2.1.0/gems/tinymce-rails-4.0.19/vendor/assets/javascripts",
".rvm/gems/ruby-2.1.0/gems/bootstrap-sass-3.1.1.0/vendor/assets/fonts",
".rvm/gems/ruby-2.1.0/gems/bootstrap-sass-3.1.1.0/vendor/assets/javascripts",
".rvm/gems/ruby-2.1.0/gems/bootstrap-sass-3.1.1.0/vendor/assets/stylesheets",
".rvm/gems/ruby-2.1.0/gems/turbolinks-2.2.2/lib/assets/javascripts",
".rvm/gems/ruby-2.1.0/gems/jquery-rails-3.1.0/vendor/assets/javascripts",
".rvm/gems/ruby-2.1.0/gems/coffee-rails-4.0.1/lib/assets/javascripts"]
Just refer it using:
//= require_tree ../../../vendor/assets/lenord-single-page-theme/css/.
Hope it helps :)
Related
I am using Rails 5 with react-rails gem. I want to use server-side rendering, but I see this error:
React::ServerRendering::PrerenderError in Home#index
Encountered error "# ExecJS::ProgramError: TypeError: Cannot read property 'serverRender' of undefined" when prerendering Main with {}
This is my /assets/javascripts/application.js:
//= require rails-ujs
//= require jquery
//= require react
//= require react_ujs
//= require_tree .
This is javascripts/components.jsx:
class Main extends React.Component{
render(){
return (
<h1>Hello</h1>
);
}
}
and this is the view:
<%= react_component('Main', {}, {prerender: true}) %>
Without prerender option, everything works.
I've had a similar issue and here's how I solved it
run command rails generate react:install
This will create the components folder and some required files under your javascripts/ dir.
Now, place your components.jsx in /assets/javascripts/componets directory
refresh the page.
I'm running rails 4.2.10 and haven't tested rails 5 but I'm guessing this should do the trick.
Let me know how you get on
I have a really interesting problem with sprockets. First of all, this is the following error message I have got.
couldn't find file 'jquery.themepunch.plugins.min' with type 'application/javascript'
Checked in these paths:
Here is the interesting part. It says a javascript plugin cannot be found, but the problem is caused in the line 13, which has a stylesheet_link_tag. How could it be possible?
Anyway, I have frontend.js and frontend.css files. Here is the content of files.
frontend.css
/*
*= require css/style
*= require css/colors/red
*= require_self
*/
frontend.js
// require scripts/jquery.themepunch.plugins.min
// require scripts/jquery.themepunch.revolution.min
// require scripts/jquery.themepunch.showbizpro.min
// require scripts/jquery.easing.min
// require scripts/jquery.tooltips.min
// require scripts/jquery.magnific-popup.min
// require scripts/jquery.superfish
// require scripts/jquery.flexslider
// require scripts/jquery.jpanelmenu
// require scripts/jquery.isotope.min
// require scripts/custom
I purposely changed //= to // in order to cancel the inclution of javascript plugins.
EDIT 1:
Here is my assets paths:
[1] pry(main)> Rails.application.config.assets.paths
=> ["/ssd/Projects/my_app/app/assets/fonts",
"/ssd/Projects/my_app/app/assets/images",
"/ssd/Projects/my_app/app/assets/javascripts",
"/ssd/Projects/my_app/app/assets/stylesheets",
"/ssd/Projects/my_app/vendor/assets/astrum",
"/ssd/Projects/my_app/vendor/assets/javascripts",
"/ssd/Projects/my_app/vendor/assets/metronic_v4.7.5",
"/ssd/Projects/my_app/vendor/assets/stylesheets",
"/home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/font-kit-rails-1.2.0/app/assets/fonts",
"/home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/font-kit-rails-1.2.0/app/assets/stylesheets",
"/home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/jquery-rails-4.3.1/vendor/assets/javascripts",
"/home/bunyamin/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/coffee-rails-4.1.1/lib/assets/javascripts",
"/ssd/Projects/my_app/vendor/assets/astrum"]
I am really stuck. How can I solve this problem? Would anyone please help? I am not requiring any javascript plugins as you can see, yet I get file not found error.
Sprockets really does not give a useful error message. I have forgot an application.js file in one of assets folder. And it automatically runs it, even though I am not calling.
Then it shows error message as if the stylesheet file is the cause.
Anyway, after removing application.js my problem is solved.
I'm working with Rails 4 and AngularJS. I've got my app working. Controllers, directives, services, etc. However, my main app.js file refuses to fire the config and run functions. I've got some console.logs in there to test how far it gets. Here's the code:
angular-app/app.js
'use strict';
console.log('we see the app.js file'); // This works
var app = angular.module('bruno', [])
console.log(app) //This works
// This is where is stops working
app.config(function ($httpProvider) {
alert('config'); // Can't see this
$httpProvider.defaults.headers.common['X-CSRF-Token'] = $('meta[name=csrf-token]').attr('content');
})
app.run(function () {
console.log('App is running'); // Can't see this
});
Like I said, my other controllers are working just fine. The console doesn't show any errors and everything loads just as it should.
Rails application.js file:
//= require angular-app/app
//= require_tree ./angular-app/templates
//= require_tree ./angular-app/modules
//= require_tree ./angular-app/filters
//= require_tree ./angular-app/directives
//= require_tree ./angular-app/models
//= require_tree ./angular-app/services
//= require_tree ./angular-app/controllers
I've re-written this every which way I can think of, but to no avail. I'm kinda stumped. I've done it with and without the var app. Hoping this wonderful community can at least help me see something I can't.
Additional Info
I'm using gem 'angular-rails-templates'
Rails 4.2.3
AngularJS 1.3.16
If you need anything else from me just ask. Who knows, maybe by tomorrow morning I'll see things differently. :-)
As it turns out, I was mistakenly re-using the same module name inside another controller. Which was overwriting the module name in app.js. All fixed now.
I'm building a Rails application and I decided to use bootstrap and sass.
I follow the guide on the github page:
https://github.com/twbs/bootstrap-sass
So, now i have my gem installed ('bootstrap-sass', 'sass-rails'), my application.css (now application.sass) looks like this:
1 #import "bootstrap-sprockets";
2 #import "bootstrap";
My application.js file looks like this:
1 // This is a manifest file that'll be compiled into application.js, which will include all the files
2 // listed below.
3 //
4 // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5 // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6 //
7 // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8 // compiled file.
9 //
10 // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11 // about supported directives.
12 //
13 //= require jquery
14 //= require jquery_ujs
15 //= require turbolinks
16 //= require bootstrap-sprockets
17 //= require_tree .
And then the guide pretty much ends.
The problem is that I don't have bootstrap in my application(I can't see it anywhere in the page by viewing the source) and I do not know how to use sass.
What should I do next? Did I miss something?
It sounds like it should all be ready to go but you will have to start writing some code that it can apply. Perhaps test it with this. In your application.html.erb file under body put the following:
<div id="container">
<div class="main">
<h1>Main Content</h1>
</div>
then in the css file try this
#container {
.main {
width:600px;
h1 {
color: $red;
}
}
Make sure you have restarted your server after the bundle install.
The list of bootstrap variables can be found here http://getbootstrap.com/customize/#less-variables
I found the error: I wrote all the import tag between the html
<title>
tag instead of the
<head>
tag.
Here is my tree
stylesheets/
admin/
admin.scss
bootstrap_and_overrides.css.less
application.css.scss
categoria.css.scss
categories.css.scss
comments.css.scss
groups.css.scss
home.css.scss
ie.css.scss
images.css.scss
images.js.coffee
specs.css.scss
1 -> Is it possible (in application.css) to don`t load bootstrap_and_overrides.css.less?
My problem is..
my app have two layouts, one of then called admin, i would like to load bootstrap only in this layout, not for all application..
everyone?
You could add all your file separately in your application.css.scss, without bootstrap_and_overrides, like this :
/**
* application-print.css
*
*= require categoria
*= require categories
...
*/
and include bootstrap_and_overrides separtely
you could place your files in a directory and use require_tree ./normal/