I have doubt in routes in rails.
In my new project i have models name as
1. Country
2. States
3. Category
4. Subcategory
5. advertisements
i want to generate routes like below
1. /en
2. /en/advertisements
3. /en/indiana
4. /en/indiana/advertisements
5. /en/indiana/cars
6. /en/indiana/cars/advertisements
7. /en/indiana/cars/bmw/advertisements
8. /en/cars/advertisements
ex :-
en is country locale
indiana is state
cars is category
bmw is sub category
Here is my routes declaration in routes.rb
scope ":language" do <br />
scope "(:state)" do <br />
scope "(:main_category)" do <br />
scope "(:category)" do <br />
resources :advertisements <br />
match "search" => "advertisements#index"
<br /> end<br />
end<br />
end<br />
end <br />
The above routes work correctly if the url is "/en/indiana/cars/bmw/advertisements"
Now i want routes for "/en/cars/advertisements"
"/en/cars/advertisements" then it will assign en to language and cars to state
How can i declare routes for this "/en/cars/advertisements",
Please help me out
Thanks in advance
Use match routes. I thought this may solve your problem.
match '/:language/:category/advertisements' => 'controller#action_name'
Related
I am using FluentValidation in Blazor WebAssembly Project.
I need to pass HttpClient into FluentValidation to do Email check ?
How do i go about it?
<EditForm Model="_editprofileModel" OnValidSubmit="UpdateProfile">
<FluentValidator TValidator="EditProfileValidator" />
<ValidationSummary />
...........
</EditForm>
I want to do something like this, but it give compiler Error "the name _Http does not exist in the current context
<FluentValidator TValidator="EditProfileValidator(_Http)" />
My current Vue app is laid out as follows:
Such that login Vue would be live under VContent, and aspects of the header and nav are be disabled based on auth state. For example, logout button if store.isAuthenticaaed. See below:
If a Register exists on the login page leading to a registration Vue, how would I break that Vue out of the parent App.vue as to not display the header or nav at all? Should I move my header/wrapper down a level and if so how?
The below answer is totally based on how I understand your requirement, happy to correct if the assumptions are wrong.
Redirecting to which page can be handled at the router configuration.
As per your layout, I can see you have
<VApp>
<VBar />
<VContent >
<router-view />
</VContent>
<VNavigationDrawer />
</VApp>
Now, your store knows whether the user is authenticated or not.
So Why not simply remove <VBar /> and <VNavigation /> using v-if. However, you need to make sure that your state is having the correct state at the initial render.
I can simply create a computed property stating
showBarAndNavigation () {
return store.isAuthenticated && this.$route.name === 'Login' && // anymore handlers
}
<VApp>
<VBar v-if="showBarAndNavigation" />
<VContent >
<router-view />
</VContent>
<VNavigationDrawer v-if="showBarAndNavigation" />
</VApp>
I need to get a relative url in the data-original attribute of img tag like this:
<img data-original="../imf/72932.png" src="../i/72932.jpg" />
But I'm getting
<img data-original="/imf/10163.jpg" src="../i/10163.jpg" />
As you can see, by setting set :relative_links, true in config.rb I can get a relative link in img's src but not in the data-original attribute with:
<%= image_tag img_url, { "data-original" => original_path } %>
where original-path is defined like this
<% original-path = "/imf/#{ wiz.file }" %>
It works of course when the site is generated dynamically in development but not when it is built statically. Is there any way to make original_path work like a relative path?
In my MVC4 application, I am using the postal package for sending emails.
I am trying to include a logo via an <img> tag, but it's not working.
How can I include my company logo?
Controller Action:
public ActionResult Index()
{
dynamic email = new Email("Example");
email.To = "xxxxx#xxxxxx";
email.FunnyLink = "haiii";
email.Send();
return View();
}
View:
To: #ViewBag.To From: lolcats#website.com
Subject: Important Message
<div style="background-color:aqua;">
Hello, You wanted important web links right?
Check out this: #ViewBag.FunnyLink
<br />
<img src="~/Images/Logo.png" />
</div>
You need to use full absolute image urls like this-
<img src="#Request.Url.GetLeftPart(UriPartial.Authority)/Images/Logo.png" />
or
If you're having html based files then you should send the domain name just like the other data you're passing into the view like this-
<img src="#ViewBag.DomainName/Images/Logo.png" />
When your email would be received by the users then the content of your email would not resolve the image path from relative urls like this -
/Images/logo.png {this will not work}
So the images can only be fetched if having full domain path.
You could use Html extension as shown below. You can refer here for more details.
<div style="background-color:aqua;">
Hello, You wanted important web links right?
Check out this: #ViewBag.FunnyLink
<br />
#Html.EmbedImage("~/Images/Logo.png")
</div>
Someone know how to change the filename of the liferay calendar event before export?
The default one is "liferay.ics".
Thanks
Sabrina
You can alter the name by writting an hook.
Override the export_import.jspf file located at %liferay_folder%\%your_server%\webapps\ROOT\html\portlet\calendar
<aui:fieldset label="export">
<aui:input cssClass="lfr-input-text-container" label="" name="exportFileName" type="text" value="liferay.ics" />
</aui:fieldset>
Changing the value attribute should do the trick.
Owk after looking a bit closer to the calendar portlet it appears that my above solution is only visible on the export/import tab and not when you export an event from the summary tab.
The endpoint who is responsible for creating the file: http://www.jarvana.com/jarvana/view/com/liferay/portal/portal-impl/6.1.0/portal-impl-6.1.0-sources.jar!/com/liferay/portlet/calendar/action/ExportEventsAction.java?format=ok
It appears that when no portlet parameter with the name exportFileName is set the action will automaticly name it liferay.ics:
Short And Easy fix:
Add (in event_action.jsp):
<portlet:param name="exportFileName" value="<%= event.getTitle() %>" />
to :
<c:if test="<%= CalEventPermission.contains(permissionChecker, event, ActionKeys.VIEW) %>">
<portlet:actionURL windowState="<%= LiferayWindowState.EXCLUSIVE.toString() %>" var="exportURL">
<portlet:param name="struts_action" value="/calendar/export_events" />
<portlet:param name="redirect" value="<%= currentURL %>" />
<portlet:param name="eventId" value="<%= String.valueOf(event.getEventId()) %>" />
</portlet:actionURL>
<liferay-ui:icon
image="export"
url='<%= exportURL %>'
/>
</c:if>
Write an wrapper arround the ExportEventsAction. (For more Advance senarios)
Use this method when more advance operations are required in the future.
http://www.liferay.com/web/mika.koivisto/blog/-/blogs/7132115
https://github.com/liferay/liferay-plugins/blob/master/hooks/sample-struts-action-hook/docroot/WEB-INF/src/com/liferay/samplestrutsaction/hook/action/SampleStrutsPortletAction.java
Wrapper basic concepts:
In your hook xml:
<?xml version="1.0"?>
<!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.1.0//EN" "http://www.liferay.com/dtd/liferay-hook_6_1_0.dtd">
<hook>
<custom-jsp-dir>/WEB-INF/jsps/</custom-jsp-dir>
<struts-action>
<struts-action-path>/calendar/export_events</struts-action-path>
<struts-action-impl>aiao.liferay.strutsactions.ExportEventActionWrapper</struts-action-impl>
</struts-action>
</hook>
Your wrapper looks like this:
public class ExportEventActionWrapper extends BaseStrutsPortletAction {
#Override
public void processAction(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
_logger.info("Call To Wrapper");
//do your magic here...
originalStrutsPortletAction.processAction(portletConfig, actionRequest, actionResponse);
}
private Log _logger = LogFactoryUtil.getLog(ExportEventActionWrapper.class);
}