I am running rails api with angularJS. my root is set to : root :to => "main#Home"
and MainController is defined as :
class MainController < ApplicationController
def Home
render :file => "public/angular/app/index.html"
end
end
in html file i link to css and some js files, and those files is in public directory. I want to avoid using rails app/assets folder since rails will only be used as API, so all the templates will be loaded by angular, i just need a way to load index page with all the styling and js.
What have i done wrong?
Edit:
One of the errors :
ActionController::RoutingError (No route matches [GET] "/bower_components/angular-route/angular-route.js"):
Related
Why am I getting the following error when the debug flag in the web.config is set to true?
Mixed Content: The page at 'https://example.com/' was loaded over
HTTPS, but requested an insecure script
'http://example.com/scripts/base/?v=JeAlpXPCZh9gYv4U-X7_HSaAX3Fj3sGBjwukxEaloQU1'.
Bundle
bundles.Add(new ScriptBundle("~/scripts/base").Include(
"~/Scripts/Base/app.module.js",
"~/Scripts/Home/home.controller.js",
"~/Scripts/Home/about.controller.js",
"~/Scripts/App/Common/dictionary.class.js",
"~/Scripts/App/Common/constants.class.js",
"~/Scripts/App/Common/multiselect.directive.js",
"~/Scripts/App/Common/paginationOptions.class.js",
"~/Scripts/App/Common/gridHeight.directive.js",
"~/Scripts/App/Common/utility.service.js",
"~/Scripts/App/Common/dateToString.directive.js",
"~/Scripts/App/Common/base.controller.js",
"~/Scripts/App/Common/messagePopover.controller.js"
));
Generated HTML
<script src="/scripts/base?v=JeAlpXPCZh9gYv4U-X7_HSaAX3Fj3sGBjwukxEaloQU1"></script>
I had a similar issue this morning. I found that the virtual path I had set was the same as the folder structure containing the scripts, once I had renamed the virtual folder path, the script bundle was then being requested over https.
Try changing the script bundle virtual path to;
bundles.Add(new ScriptBundle("~/scripts/applicationBase").Include(
"~/Scripts/Base/app.module.js",
....,
....
));
Hope that helps
I have 2 bundle MyBundle1 and MyBundle2 , MyBundle2 inherits MyBundle1.
In /app/config/services.yml i have:
imports:
- resource: '#MyBundle1/Resources/config/services.yml'
- resource: '#MyBundle2/Resources/config/services.yml'
The problem is that '#MyBundle2/Resources/config/services.yml' will be considered as '#MyBundle1/Resources/config/services.yml' because it inherits it, so override its files.
My question is: How can I access to the real '#MyBundle2/Resources/config/services.yml', not the one rewritten ?
Thanks
The Symfony cookbook explains that Bundles override their parent Bundles resource files when
they're in the same location inside the bundle
They've been imported using the #MyBundle/...../services.yml (the #-part) syntax.
In order to have your Bundle not override your parent Bundles services you can use a different filename (eg. _services.yml) or refer to it using the full path in your config.
I have a Spring Boot 1.3 application (deployed as .war) that needs to be able read a .properties file from the following location:
WEB-INF/application.properties (outside the classpath, but relative to the app root folder)
...as opposed to:
WEB-INF/classes/application.properties(inside the classpath, gets loaded automatically)
What worked in Spring Boot 1.3 was the following #PropertySource annotation:
#SpringBootApplication
#PropertySource(value = {"WEB-INF/application.properties"})
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
}
It correctly fetched the .properties file relative to the app root. However that stops working after an update to Spring Boot 1.4.0.RC1.
Since then I've tried the following:
#PropertySource("classpath:../application.properties")
#PropertySource("file:WEB-INF/application.properties")
and also
spring.config.location=classpath:../
spring.config.location=file:src/main/webapp/WEB-INF/
spring.config.location=WEB-INF/application.properties
But haven't had any luck loading the .properties.
I'd normally put the .properties file inside the classpath, but in this case this is NOT an option due to the way our deployment works on a remote location.
I'd also prefer to not use an absolute path, as that'll be a nightmare to support with multiple customers.
Edit: Just to be clear - the .properties I'd like to read aren't located outside the JAR (in my case - WAR) file, but inside - just not on the classpath, but directly in the WEB-INF/ folder where normally other resources (pages, images) would be.
As I mentioned in duplicate SO question:
Put this line into your application.properties:
logging.config=file:log4j.xml
Second option is to pass system variable to -Dlogging.config=file:log4j.xml
In this case it is expected to be located in current directory outside of the JAR file.
REACTION ON COMMENT:
If you are using WAR file, your main class is not used at all. So PropertySource annotation doesn't have any effect there.
If the .properties is packed in the .war file. Then you can try the following (assuming that the WEB-INF directory is located in the root of the .war file.
#PropertySource("classpath:/WEB-INF/conf/application.properties")
Turns out this issue was caused by a bug with the SpringBootTestContextBootstrapper in Spring Boot 1.4.0.RC1: https://github.com/spring-projects/spring-boot/issues/6371
i've set up a GWT project using Gradle as build management and everything is fine.
I can deploy my project to my local tomcat in eclipse and the application runs as intended.
But if I start the DevMode and change something in my css resources (which are bound as CssResource classes with an #Source annotation), the GWT DevMode doesn't catch it and the css changes are not taken into account.
Am I missing something? I would expect the DevMode to detect changes in .css files during development without having to run a gwt compile again.
Here is an example of how i am using the css resources:
public interface XOFooterPanelResource extends FooterPanelResource, ClientBundle {
#Override
#Source("XOFooterPanel.css")
XOFooterPanelStyle style();
#Override
#ImageOptions(repeatStyle = RepeatStyle.Horizontal)
ImageResource footerPanelBackground();
#Override
#ImageOptions(repeatStyle = RepeatStyle.Horizontal)
ImageResource footerPanelBackgroundEndUser();
#Override
#Source("footerDelimiter.jpg")
ImageResource footerDelimiter();
}
public interface XOFooterPanelStyle extends FooterPanelStyle, CssResource {
}
As you can see i have my XOFooterPanelStyle interface which extends CssResource. It is used in the XOFooterPanelResource - which extends ClientBundle - by using the #Source annotation with the name of my CSS file.
And here is the part of my gradle build file which is responsible for starting the DevMode:
javaexec {
main = 'com.google.gwt.dev.DevMode'
jvmArgs = ['-Xmx2048M', '-XX:MaxPermSize=1024M']
classpath {
[
sourceSets.main.java.srcDirs,
// Java source
sourceSets.main.output.resourcesDir,
// Generated resources
sourceSets.main.output.classesDir,
// Generated classes
sourceSets.main.compileClasspath // Deps
]
}
args = [
'-startupUrl',
'myapp/index.html',
'-noserver',
'-war',
'build/devmode',
'-gen',
'gen'
]
ext.gwtModules.each {
args += it
}
}
As mentioned before i'm using tomcat inside eclipse to run the application, so the -noserver option is set.
Unless you are directly changing the css file that tomcat is referencing, you will not see the changes in dev mode. I believe that when you deploy via tomcat in eclipse, your code is not referenced directly from the eclipse project workspace, a copy is moved to the tomcat webapps folder.
I'm not sure what the standard way around this is. I feel like there has to be an option to refresh static resources to the tomcat instance from eclipse, but I haven't looked into it.
Here are two ways i've gotten around the issue when I needed to:
1) You can put CSS code in your ui.xml files, and that should get picked up by devMode.
Tutorial on how to add css to your ui.xml
2) You could also modify the css file in the webapps folder directly, then migrate any changes you made back to the workspace version.
I have something like this:
bundles.Add(new StyleBundle("~/Content/Styles/Default/Forums").Include("~/Content/Styles/Default/Forums/Main.css",
"~/Content/Styles/Default/Forums/Slider.css"));
Now, when i release my application and run it, it creates a link like this:
<link href="/Content/Styles/Default/Forums?v=8vn0bgRpB8BncmaT_onrpNlXa4t9ydK6_Fep81xhhm01" rel="stylesheet"/>
Which refers to my site directory, and access to that is disabled. But ASP doesn't let me specify files outside of the application, then how can I do it properly?
The virtual path in the StyleBundle constructor doesn't have to match an existing path in your application:
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/Styles/Default/Forums/Main.css",
"~/Content/Styles/Default/Forums/Slider.css"));
If you want to use external files, you can use the CDN path on the bundle (you need to set the UseCDN property to true):
bundles.UseCdn = true;
bundles.Add(new StyleBundle("~/Content/css", "<CDN Path>").Include(
"<CDN Path>/Main.css",
"<CDN Path>/Slider.css"));