w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Block access to link - Can Can Rails
Without seeing your current show method, routes, or models: def show if Branch.exists?(params[:id]) @branch = Branch.find(params[:id]) @branches = Victim.where (:branch_id => @branch.id) else if @branch.nil? || @branch.email != current_user.email log_message = "Current User #{current_user.email} was blocked from viewing a branch " log_message += "owned by #{@branch.email}" if @branch log_message += "#{params[:id]} that does not exist" if @branch.nil? logger.warn log_message redirect_to action: "index" else logger.debug "Current User #{current_user.email} was allowed to view a branch with the email #{@branch.email}" end end Basically, in your show method, all you have to do is validate that the user

Categories : Ruby On Rails

handlebars conditional block
You can use this: Handlebars Template (Tipically used like a .hbs file or a string variable): {{#if myValue}}value="{{myValue}}"{{/if}} Javascript: //Where template is your handlebars template var myTemp = Handlebars.compile(template); //This console.log will print value="hi" console.log(myTemp({ myValue: "hi" })); The previous code will write myValue only if exists or contains a falsy value ("", 0, false); You have a JSFiddle with your specific example: http://jsfiddle.net/vy2qK/

Categories : Javascript

Conditional formatting VBA different cell as condition
In Excel 2010 there's no need for VBA. place Excel cursor in cell (y, cellcounter) and click [Conditional Formatting] - [New Rule...] from the Styles section of the Home ribbon click "Use a formula to determine which cells to format" place cursor in field "Format values where this formula is true" click in cell (x, cell counter) ... it will show e.g. =$A$1 (i.e. the reference of the cell delivering your condition) add ">0" to formula and select the format You can apply the same rule to multiple cells using [Conditional Formatting] - [Manage Rules...], so all cells will turn red if condition cell goes from 0 to 1. To do the same in VBA, use the following methods and properties: {target range}.FormatConditions.Add Type:=xlExpression, Formula1:="=$A$1>0" {target range}.FormatConditio

Categories : Vba

Magento conditional block in layout xml
The only way I know of to do if statements in configs is the use the ifconfig but that is not what you want. In your case what I would suggest is having a master block with sub blocks then put your conditional statement in the master template and use $this->getChildHtml('child_name'). That way you can put your logic in a template and not pollute your configs (I think there might be a way). Config: <block type="core/template" name="master_block" template="folder/path/master_block.phtml"> <block type="core/template" name="sub_block_form1" template="folder/path/form1.phtml" /> <block type="core/template" name="sub_block_form2" template="folder/path/form2.phtml" /> </block> In folder/path/master_block.phtml: <?php if ($this->so

Categories : PHP

Using calling method name as condition for conditional statement
.NET 4.5 introduces a few new attributes that give you this kind of information. The CallerMethodNameAttribute: Allows you to obtain the method or property name of the caller to the method. public OperationStat Update(object obj, [CallerMethodName] string calledFrom = "") { OperationStat op = new OperationStat(); string callmethod = "Add"; if(calledFrom != callmethod) { op.Primarykey = pkey.newkey(); } return op; }

Categories : C#

ANT condition block
Equivolent pseudo code: if (File($create_stub_command_file).exists) then property["stub_script.present"] := true end if (File($create_stub_command_file).exists AND property["property["stub_script.present"] != NULL) then property["create_stub"] := true end Forgive any errors... I find condition blocks tricky and they need lots of testing. You're best advised to keep them simple. ANT is not a programming language.

Categories : Ant

Conditional breakpoint in Visual Studio - condition using non basic data types
Assuming you do not want to compare object pointers to null pointer, which is trivial; yes, you can put such a condition. However, you need to overload equality operator == for related MyClass: class MyClass { public: MyClass() { someMember = 0; // let this be null object condition } MyClass(int member) { someMember = member; } bool operator == (const MyClass &Ref) const { return(this->someMember== Ref.GetMember()); } const int GetMember() const { return(this->someMember); } private: int someMember; }; #define NULL_OBJ MyClass() By #define NULL_OBJ MyClass(), you can define a null object and compare any MyClass obj

Categories : C++

jquery validate with conditional custom method. Condition not working as expected
Check this fiddle, i think this will help you achieve your req var require_state = true; jQuery.validator.addMethod("greaterThanZero", function(value, element) { return this.optional(element) || (parseFloat(value) > 0 || require_state); }, "* Amount must be greater than zero"); http://jsfiddle.net/Shinov/DfyqE/1/

Categories : Javascript

Conditional Loading of CSS files based on test condition in JQuery plugin
I am not sure how to implement document.ready, as my plugin's constructor needs to run only when the DOM is ready. There are two relevant events window.addEventListener('load', function () { // code runs when document+resources have finished loading }); and document.addEventListener('DOMContentLoaded', function () { // code runs when document has finished parsing, but before resources loaded }); If you wait for either of these events before importing jQuery, I'm not sure what effect it will have on jQuery's inbuilt $(document).ready / similar. That said, you do have the option of checking document.readyState === 'complete' before attaching listeners, to see if you should invoke straight away.

Categories : Javascript

Is there a way to find out which IF condition 'triggered' the entrance into if (){ } block?
Try if (object instanceof SomeThing ) { System.out.println("this block was entered because of: " + **SomeThing ____** ) } else if(object instanceof OtherThing){ System.out.println("this block was entered because of: " + **OtherThing____** ) } else{ System.out.println("********nothing satisfied) }

Categories : Java

Multi-conditional join through a link table
I'd do it this way: SELECT pages.*, tags.tag_name, taggroups.group_name FROM tags_to_pages JOIN taggroups AS grp ON grp.taggroup_id = tags_to_pages.taggroup_id JOIN tags AS val ON val.taggroup_id = grp.taggroup_id JOIN pages ON tags_to_pages.page_id = pages.page_id WHERE grp.group_name='fruits' AND val.tag_name = 'apple' This isn't that different to what you have, but I'm putting the join criteria in the JOIN clauses and the selection criteria in the WHERE clauses, which seems tidier to me. While re-typing this query I spotted that you were using a tag_id somewhere I thought should have been a taggroup_id, so I changed it, but I regret I can't see it again now. I'd also worry about the selection criteria - what if an apple doesn't happed to be a fruit? Obvi

Categories : Mysql

wordpress conditional change login logout link
Your conditional should look like this: <?php if ( is_user_logged_in() ): ?> <a href="<?php echo wp_logout_url( $_SERVER['REQUEST_URI'] ); ?>">Logout</a> <!-- This redirects the user to the current page after logout. --> <?php else: ?> <a href="<?php echo wp_login_url( $_SERVER['REQUEST_URI'] ); ?>">Login</a> <!-- This redirects the user to the current page after login. --> <?php endif; ?>

Categories : Wordpress

image link not working and ie conditional styles not showing up
There could be a format I'm not aware of, but your IE conditionals look incorrectly formatted. Rather than [if IE] #stupidie{ left: -4px !important; top: 1px !important; } It should be <!--[if IE]> #stupidie{ left: -4px !important; top: 1px !important; } <![endif]--> UPDATE The issue with your link not working is due to you z-indexes. You have a whole mess of them throughout the page and it appears that the #body_layer div is covering your sidebar. When I remove the z-index property from the CSS, it allows you to click on the link. that does break the rest of your page though. The other thing you could do is change the width of #body_layer to ~500px. That keeps it from overflowing onto the sidebar and covering your link.

Categories : CSS

PHP regex conditional get content and link from HTML anchor tag
Try this: preg_match_all("/<a href="(.*)"[^>]*>([a-zds]{30,})<\/[a-z]+>/si", $match[0],$posts); Since you have the i case-insensitive modifier, you don't need both a-z and A-Z in your classes. And if you're just setting a minimum length of the content, you don't need to specify a maximum of 999; {30,} means 30 or more.

Categories : PHP

Conditional link static library in XCode with environment variable
In the end I ended up solving this problem by adding more parameters to the xcodebuild command line. Basically what you need to do is to adjust: Where the header .h files are located Where the library .a is located Tell the linker that you want to use the library -lCrittercism_v4_0_7 /usr/bin/xcodebuild -configuration Release clean "LIBRARY_SEARCH_PATHS=${LIBRARY_SEARCH_PATHS} ${PROJECT_DIR}/Libraries/CrittercismSDK" "HEADER_SEARCH_PATHS=${HEADER_SEARCH_PATHS} ${PROJECT_DIR}/Libraries/CrittercismSDK" "OTHER_LDFLAGS=-lCrittercism_v4_0_7" With this approach you don't need to add the library to the target or to Xcode at all. If the last three parameters aren't added to the command line, the library won't belong to the final executable at all.

Categories : IOS

Objective c - Run block of code for X seconds but return immediately if condition satisfies
Don't block or poll. set a timer for 5 seconds if whatever condition is met, check the condition after 5 seconds and do the fail case or success case if necessary if you want to take action immediately on completion, then use any of the various "perform thing on main thread" constructs to do so (also setting the condition to let the timer firing no that the task was done) you can invalidate the timer to keep it from firing at all, if you want.

Categories : Objective C

ItemTemplate not show link under certain condition
I would recommend using the RowDataBound event in your code behind file. It will give you the ability to customize data and properties of each row. In here you can target your LinkButton and add (or remove) the desired text and also change the CommandArgument value if needs be based on your situation.

Categories : C#

css: block link not fitting correctly
The problem was your padding applied to your LI. Removing that made the <a> fill your LI. http://jsfiddle.net/Tx8MK/5/ html, body { margin: 0; padding: 0; } body { font: 13px/22px Helvetica, Arial, sans-serif; background: #f0f0f0; } nav { position:absolute; top:0; width:100%; background: #000; color: #fff; list-style: none; } nav section{ margin:10px 20px; } #navBar li{ float:left; display:block; text-align:center; position:relative; margin-right:30px; border:none; } #navBar li:hover{ border: 1px solid #777777; border-bottom:none; /* Background color and gradients */ background: #F4F4F4; background: -moz-linear-gradient(top, #F4F4F4, #EEEEEE); background

Categories : CSS

Possible bug in rails conditional validation?
You could put the if validation in a proc. "Symbol-only" conditional validation expects a symbol for the name of a method that will be called. You're including conditionals, which AFAIK won't work without being in a proc. You can do some combinations by using an array, as per the docs: class Computer < ActiveRecord::Base validates :mouse, presence: true, if: ["market.retail?", :desktop?] unless: Proc.new { |c| c.trackpad.present? } end But those are and, not or. I'd probably wrap it up in a method anyway; IMO it's a bit long for an in-line block, but that's more a matter of opinion.

Categories : Ruby On Rails

Conditional has_many in rails 2
The solution I went with was to add raw SQL to find() call. Wrote my joins manually and then edited the view to suit the different output. Not what I would have preferred to do, but it works.

Categories : Ruby On Rails

Ruby Rails Query In conditional
You were on the right track with IN. Here's syntax that will work in Rails 3+: EventType.find(3).events.where("id IN (?)", [1,2,3]).include(:sheet => :rink) Improvement from a comment removes SQL entirely: EventType.find(3).events.where(:id => [1,2,3]).include(:sheet => :rink)

Categories : SQL

Using Rails as_json with conditional statement
I solved this problem by creating a method called image_path in my Projects model: (I needed the method to return three types of images) def image_path images = Hash.new if first_step.images.present? images["url"] = first_step.first_image.image_path_url images["preview"] = first_step.first_image.image_path_url(:preview) images["thumbnail"] = first_step.first_image.image_path_url(:thumb) end return images end Then I edited my JSON to look like this: "projects": <%= JSON.pretty_generate(@projects.order("updated_at DESC").as_json(only: [:title, :id, :built], :methods=> [:image_path, :updated_at_formatted])).html_safe %> This gets rendered like this on my website: "projects": [ { "bu

Categories : Ruby On Rails

Javascript conditional in Rails with Turbolinks?
If the wrong things are fading out when you click on links, it may be because you are not resetting hasBeenClicked after each fade. If you click a .commentLink, the .commentBit will properly fade out, but then because hasBeenClicked is still true, any other link click will prompt the same behaviour. Reset hasBeenClicked to false after fading out .commentBit.

Categories : Javascript

Rails form_for conditional parameters
You need to pass the block to my_form. The way to do that is to include a yield where you want the block to go: def my_form if some_condition form_for(@model) { |f| yield f } else form_for [@model, @nested_model] { |f| yield f } end end This should take the block you pass in your view: my_form do |f| # Really a lot happens here end

Categories : Ruby On Rails

Conditional div with a variable in a rails view
You want to start off with double quotes and not single quotes for string interpolation to work. Try: <%= "<div class='search_wrapper_inner #{group_class}' >".html_safe if defined?(group_class) %> Here is the test for it in rails console: > group_class = "test" => "test" > '<div class="search_wrapper_inner #{group_class}" >'.html_safe => "<div class="search_wrapper_inner #{group_class}" >" > "<div class='search_wrapper_inner #{group_class}' >".html_safe => "<div class='search_wrapper_inner test' >"

Categories : Ruby On Rails

Block direct link of an image but keep displaying it in pages
Change your .htaccess code with this: Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase /test/ # block direct access to images RewriteCond %{HTTP_REFERER} !^http://(www.)?myserver.com/ [NC] RewriteRule ^(.+?.(?:png|gif|jpe?g))$ img.php?path=$1 [L,NC]

Categories : Image

how to display cart icon in block permanent link
In your first image, you have two modules at top : blockcurrency and blockpermanent module. In your second you have an additional third module called blocklanguage. The cart icon or section you see is actually blockcart module. If you want to move it to the permanentlinks section, then you have to work around with CSS and modules positions. There is no other good way to do this, but if it is difficult for you to do with simple css and module positions, then you can do it the other way as below: Blockpermanentlinks module has only some static links, it means you can copy its links in the blockpermanentlinks.tpl file and place them in the cart module tpl file, after that you have to work around with a little bit html and css to achieve your required results. Hope this will help you.

Categories : PHP

Issue with P tag content covering a block level link
You can change some bits to put it to work as you'd expect: On the jquery.barousel.js file, look for this snippet: //build the navigation if (settings.navType == 1) { //items navigation type var strNavList = "<ul>"; And change it, by adding a class (navigationMenu) to the ul: //build the navigation if (settings.navType == 1) { //items navigation type var strNavList = "<ul class='navigationMenu'>"; On your page header, after you load all the libraries, add the snippet below: <script type="text/javascript"> $(function () { // Look for all the spans which contains the class abs, and move them // to the li accordingly. $("span.abs").each(function (index, element) { var target = $("ul.navigationMenu li")[i

Categories : Jquery

Trouble understanding block device API- any good link?
This link is great (it's a chapter from a great book named Linux Device Drivers): http://lwn.net/images/pdf/LDD3/ch16.pdf

Categories : C

Rails ActiveRecord conditional validations for associated models?
Not sure if this is sufficient, but one possibility is to accept that when proposal is nil, proposal_is_draft? is effectively true. In that case, you could redefine it to: def proposal_is_draft? !proposal.persisted? || proposal.draft? end Though this looks doesn't look great, it would return true when the proposal is not persisted, and return true when the proposal is a draft (changed from status.draft to use the method you defined in Proposal class).

Categories : Ruby On Rails

Enable/Disable Link Buttons in Gridview Depending on Condition
On your gvData _OnRowDataBound , check for the condition and make the appropriate buttons Visible property to false for each row. protected void gvData_OnRowDataBound(object sender, GridViewRowEventArgs e) { LinkButton lbClose = (LinkButton)e.Row.Cells[5].FindControl("lbClose"); LinkButton lbEdit = (LinkButton)e.Row.Cells[5].FindControl("lbEdit"); LinkButton lbDelete = (LinkButton)e.Row.Cells[5].FindControl("lbDelete"); LinkButton lbWrite = (LinkButton)e.Row.Cells[5].FindControl("lbWrite"); LinkButton lbRT = (LinkButton)e.Row.Cells[5].FindControl("lbRT"); if(e.Row.Cells[1].Text=="Dessert") { lbClose.Visible = false;

Categories : C#

Placing a block element a link inline with form elements
try a.addremove{ display:block; float:left; background-color: #4B5E75; color: #fff; margin: 0; width: 32px; height: 32px; font-size:16px; text-align: center; line-height: 38px; border-radius: 50%; }

Categories : HTML

Conditional Rails Form Actions based on Javascript
Couple of options: Have two different submit buttons (one for each form) and then actually have this be part of the tab content instead of the modal-footer. Generate two modal footer divs and set the second one to display: none. Then through javascript toggle the visibility appropriately. I'd probably take this approach. Via javascript override the form target based on the tab that gets clicked.

Categories : Jquery

where condition is not working in rails
First confirm that params[:city] is the city id and not city name. Then try changing to Hotel.where(["city_id = ? and hotels LIKE %?%", params[:city], params[:search]])

Categories : Ruby On Rails

problems with if condition in rails
You have to make it like this :- <% if @orbituarysite.notice_display.nil? %> <%= render 'notice_displays/form' %> <% end %> in notice_displays/_form <%=form_for....., :remote => true%>

Categories : Ruby On Rails

Rails after commit condition
Got it. Called another callback before_update and self.status_changed? value is stored in a flag as @flag = self.status_changed? Thanks to this article - http://axonflux.com/offlining-denormalized-tasks-gotchas-with-off. Also cheers to Dave Newton for the kind help.

Categories : Ruby On Rails

Block helpers in rails
Roughly: def needs_clearance(level, &block) if current_user.clearance >= level capture(&block) end end Block helpers generally look like the following, e.g., to wrap something in a div: def box(&block) "<div class='box'>" + capture(&block) + "</div>" end From: http://timelessrepo.com/block-helpers-in-rails3 I'd consider reading that, too, as it discusses an interesting consequence of block helpers.

Categories : Ruby On Rails

Rails - validation ignores condition
You've used hidden_field_tag so you are causing params[:validate_step] to be set instead of params[:user][:validate_step]. As a result the value never makes it to your model, so step_two will always return false. Instead you should use f.hidden_field :validate_step, :value => 'two'

Categories : Ruby On Rails

Rails - Simplify WHERE condition IS NOT NULL
The Squeel gem will allow you to use != nil type syntax, but natively rails will not. Example: Model.where{column != nil}

Categories : SQL

Rails show form value only if condition
I strongly suggest to put your logic inside a helper method: module UserHelper def name_input(instance, f, options = {}) options[:html_options] ||= {} f.text_field :name, options[:html_options] if instance.name.include?('@') end end Then in your view: <%= name_input(@user, f, html_options: { class: 'text_field' }) %> If you want to simply hide the value you can do: <%= f.text_field :name, value: @user.name.include?('@') ? @user.name : '' %> Feel free to move this to a helper method also.

Categories : Ruby On Rails



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.